db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmclea...@comcast.net
Subject Re: MySQL TO_DAYS() emulation in Derby
Date Fri, 15 Sep 2006 13:32:08 GMT
Java calendar and date objects work in miliseconds but I think that fields marked as "date"
rather than timestamp just have their hour/minute/second parts set to 0. Even so, it's fairly
easy to roll a timestamp back to 00:00:00. You can then subtract the Date.getTime() values
and divide by 86,400,000 to get days.

Or am I missing something obvious here?

Donald

 -------------- Original message ----------------------
From: Robert Enyedi <robert.enyedi@intland.com>
> Michael,
> 
> As far as I know, year 0 in MySQL is actually 1 AD. However, it doesn't 
> necessarily matter when that year is when you have the comparability of 
> the results.
> 
> What matters that this function in combination with its reverse, 
> FROM_DAYS, allows easily for one to compute things like:
> - are both timestamps in the same day? TO_DAYS(tstamp1) = TO_DAYS(tstamp2)
> - how many days are between the two dates? TO_DAYS(date1) - TO_DAYS(date2)
> - what is the date if one adds X days to a specified date? 
> FROM_DAYS(TO_DAYS(date1) + X)
> 
> I'm not specifically in love with this function either, but what other 
> alternatives does Derby offer to make these computations?

Mime
View raw message