Re: [sqlite] CURRENT_TIMESTAMP precision
Please ignore my previous post. Doug's suggestion is much better. ~Eric Eric Minbiole wrote: >> I would like CURRENT_TIMESTAMP to be more accurate than just one second, >> any suggestions on how I might do that once? My solution is all a C/C++ >> interface, so all features are open to me. > > One option would be to create and register a custom SQL function that > returned the current time, including fractional seconds. If you format > your result as "-MM-DD HH:MM:SS.SSS", then all standard SQLite date > functions should work as-is (up to millisecond resolution). > > Of course, how you actually get the time from the O/S will depend on > your particular O/S. For windows, GetSystemTimeAsFileTime() may be of > use. (Resolution around 1~16ms depending on O/S version.) I'm sure > others can help with APIs for other Operating Systems. > > Some links: > > http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions > http://www.sqlite.org/c3ref/create_function.html > http://msdn.microsoft.com/en-us/library/ms724397(VS.85).aspx > > ~Eric > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] CURRENT_TIMESTAMP precision
> I would like CURRENT_TIMESTAMP to be more accurate than just one second, > any suggestions on how I might do that once? My solution is all a C/C++ > interface, so all features are open to me. One option would be to create and register a custom SQL function that returned the current time, including fractional seconds. If you format your result as "-MM-DD HH:MM:SS.SSS", then all standard SQLite date functions should work as-is (up to millisecond resolution). Of course, how you actually get the time from the O/S will depend on your particular O/S. For windows, GetSystemTimeAsFileTime() may be of use. (Resolution around 1~16ms depending on O/S version.) I'm sure others can help with APIs for other Operating Systems. Some links: http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions http://www.sqlite.org/c3ref/create_function.html http://msdn.microsoft.com/en-us/library/ms724397(VS.85).aspx ~Eric ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] CURRENT_TIMESTAMP precision
On May 15, 2009, at 9:07 AM, Sam Carleton wrote: > I would like CURRENT_TIMESTAMP to be more accurate than just one > second, any suggestions on how I might do that once? My solution is > all a C/C++ interface, so all features are open to me. Option 1 - use: julianday('now') instead of CURRENT_TIMESTAMP Option 2 - modify ctimestampFunc in date.c Presently ctimestampFunc uses datetimeFunc; datetimeFunc doesn't return fractional seconds. e ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] CURRENT_TIMESTAMP precision
I would like CURRENT_TIMESTAMP to be more accurate than just one second, any suggestions on how I might do that once? My solution is all a C/C++ interface, so all features are open to me. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users