in

System.Data.SQLite

An open-source, enhanced version of the SQLite database engine for Windows

Current_TimeStamp returns wrong datetime

Last post 10-01-2007 9:40 AM by Robert Simpson. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-27-2007 4:01 PM

    • ZNS
    • Top 500 Contributor
    • Joined on 09-14-2007
    • Posts 3

    Current_TimeStamp returns wrong datetime

    Hi.

    I'm sure this is some configuration issue, but I have a field with Current_TimeStamp as default and it inserts the wrong datetime, it's off about -2 hours compared to the server date. Any solutions?

  • 09-27-2007 4:57 PM In reply to

    Re: Current_TimeStamp returns wrong datetime

    CURRENT_TIMESTAMP inserts date/times in UTC (system time -- no timezone).  I suspect you are either GMT+2 or GMT-2, and you are comparing local time to SQLite's system time.

    Robert

     

  • 10-01-2007 8:07 AM In reply to

    • ZNS
    • Top 500 Contributor
    • Joined on 09-14-2007
    • Posts 3

    Re: Current_TimeStamp returns wrong datetime

    Sorry for the slow update on this, but haven't had the time to check up on it. Unfortunately it inserts a time that is two hours before mine, even though I am GMT+1. But maybe I have to account for daylight savings time myself also?

  • 10-01-2007 8:53 AM In reply to

    • Nate
    • Top 10 Contributor
    • Joined on 08-28-2005
    • Fort Collins, CO
    • Posts 67

    Re: Current_TimeStamp returns wrong datetime

    http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions 

    sqlite> select current_timestamp;
    2007-10-01 15:49:58
    sqlite> select datetime(current_timestamp, 'localtime');
    2007-10-01 09:50:37

    Filed under:
  • 10-01-2007 9:40 AM In reply to

    Re: Current_TimeStamp returns wrong datetime

    Personally, I record all the dates and times in my databases as UTC and convert them to local time when I need to display them.  That way no matter where my code gets moved and no matter what timezone the computer is configured for, I always display the right time.  It also prevents two computers running on two different timezones from inserting datetimes into the database in their own local time and really messing things up.

    Robert

     

Page 1 of 1 (5 items)
Powered by Community Server (Commercial Edition), by Telligent Systems