On Sep 17, 2011, at 9:29 PM, Igor Tandetnik wrote:

>> So how come does julianday take the time part of date into consideration 
>> even when it's not provided?
> 
> It doesn't.

Hmmm...

http://en.wikipedia.org/wiki/Julian_day#Converting_Gregorian_calendar_date_to_Julian_Day_Number

local math = require( 'math' )
local floor = math.floor
local year = 2002
local month = 8
local day = 28
local a = floor( ( 14 - month ) / 12 )
local y = year + 4800 - a
local m = month + 12 * a - 3
local jdn = day + floor( ( 153 * m + 2 ) / 5 ) + 365 * y + floor( y / 4 ) - 
floor( y / 100 ) + floor( y/ 400 ) - 32045

print( jdn )

> 2452515

In SQLite:

> select julianday( '2002-08-28' );
2452514.5

> 
>> JD 2452514.500000 is
>> CE 2002 August 28 00:00:00.0 UT  Wednesday
>> 
>> JD 2452514.000000 is
>> CE 2002 August 27 12:00:00.0 UT  Tuesday
> 
> Looks OK to me. What again seems to be the problem?

I was expecting a julian day number. SQLite's julianday function returned a 
julian date (including a time portion).

>> Or did I miss something?
> 
> Apparently.

Perhaps :)

In any case, will stick with cast and round and call it a (julian) day:

> select cast( round( julianday( date( 1030561675, 'unixepoch', 'utc' ) ) ) as 
> integer );
2452515



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to