denisgolovan <denisgolo...@yandex.ru>
wrote:
> I'd like to ask a question about 2038 year unix problem.
> I've found a mention about it on on
> http://www.sqlite.org/cvstrac/wiki/wiki?p=DateAndTimeFunctions wiki
> page.
> Though I cannot grasp the idea of the following phase:
>
> "Also, the localtime() C function normally only works for years
> between 1970 and 2037. For dates outside this range, SQLite attempts
> to map the year into an equivalent year within this range, do the
> calculation, then map the year back. "
>
> Does it mean 2038 must be a problem or not?

When you do something like

select datetime('2038-12-31T00:00:00', 'localtime');

SQLite has to convert the time you gave from UTC to local time. It uses 
localtime() C function for this. On many systems, this function only 
accepts dates between 1970 and 2037. To work around this, SQLite 
actually passes a different date to the function: it has the same month, 
day and time as the one you specify, but different year (adjusted so 
that it falls into an accepted range). After localtime() call, it 
adjusts the year back by the same amount.

> Now I'm trying to deal with 2038-2039 year dates, but function date
> just returns nulls for all such date strings. Maybe I miss something?

This works for me

select date('2038-12-31T00:00:00');

and returns the expected value of '2038-12-31'. Show the exact code you 
have a problem with.

Igor Tandetnik 



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

Reply via email to