baavgai: (Default)
( Jan. 3rd, 2007 12:23 pm)
Most systems reckon time as a function of the date and the time. All databases I know of do this. Even those that say they have a different type for date and time just usually just hide the other half.

Oracle's method of storage is kind of neat. It's a big number that's the number of days since the year 1700. The time is a fraction. So, to get just a date, Oracle has this:

select trunc(sysdate) from dual

If you don't know this, there is an ugly hack that takes advantage of character conversions to cut off the time, it looks like this:

select to_date(to_char(sysdate,'YYYYMMDD'),'YYYYMMDD') from dual

Micrsofts SQL Server doubtless has a similar mechanism somewhere. However, the equivalent of Oracle's trunc(sysdate) doesn't seem available. There are many methods out there, all kind of cludgy. That character conversion hack for Oracle I noted? Well, that kind of method is the best I've found for SQL Server. And here is is:

SELECT CONVERT(datetime, CONVERT(varchar(10), GetDate(), 101))

Please, if anyone finds a better one, let me know.
Tags:
I played with Second Life for a few months last year. Long enough to make some toys and release them as Open Source examples before I lost interest.

One thing that's ubiquitous in SL are "pose balls", objects that animate your avatar in certain ways when you sit on them. While everywhere, there were no good examples. Some common ones were horrid, using timers where they didn't have to. The good code that was Open Source was part of larger, more complex things. So, I wrote a simple pose ball.

I thought it was good code, much cleaner and friendlier than most of the stuff I found. Apparently, I'm not the only one. Six months since I've logged in, I now get coding questions and help requests from people who bought something from someone who used that code (GPL be damned, I guess).

I don't whether to run like hell or log in and take a look around. I never did finish a molecule modeler I was working on; Second Life would be far more entertaining if not for all the porn... :p
.

Profile

baavgai: (Default)
baavgai

Links

Most Popular Tags

Powered by Dreamwidth Studios

Style Credit

Expand Cut Tags

No cut tags