[Qt-interest] [Solved] Strange problem storing and retrieving and comparing QTime/QDataTime

Mihail Naydenov mlists at ymail.com
Tue Nov 17 18:07:44 CET 2009


Yes, thank you, Thiago , binding a QDateTime to a table field value saves it as Qt::ISODate, which has signature YYYY-MM-DDTHH:MM:SS
this obviously discards the milliseconds. 
When read back the milliseconds are reset to zero.

So, if one first converts the datetime toString("dd.MM.yyyy hh:mm:ss.zzz") before binding
than later reads it back as string first (not toDateTime() on the table data QVariant) and builds the datetime manually, using the string and the same signature ("dd.MM.yyyy hh:mm:ss.zzz") everything is ok :) (assuming sqlite)

I guess its easier to just convert toTime_t instead.

Thanks again
MihailNaydenov


----- Original Message ----
> From: Frank Hemer <frank at hemer.org>
> To: qt-interest at trolltech.com
> Sent: Tue, November 17, 2009 5:04:24 PM
> Subject: Re: [Qt-interest] Strange problem storing and retrieving and comparing QTime/QDataTime
> 
> On Tuesday 17 November 2009 15:40:49 Thiago Macieira wrote:
> > Now, remember that QDateTime keeps the time precision in *milliseconds*,
> > whereas time_t has a resolution of seconds. My guess is your roundtrip
> > through the database discarded the millisecond component (your source was
> > file.lastModified(), which does have millisecond resolution).
> 
> Also note that some databases (depending on the date type used) don't have a 
> millisecond precision (mssql has ~3msec precision by default).
> 
> Frank
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest



      



More information about the Qt-interest-old mailing list