David Higgs
Programmer
A Field (BigInt) in a 3rd Party application contains a Value of 20170411165506093
The format is: YYYYMMDDHHMMSSnnn, ie Datetime with Millisecs
How do add millisecs to Datetime?
Regards,
David.
Recreational user of VFP.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
How do add millisecs to Datetime?
tDateTime = DATETIME(2018, 8, 12, 11, 16, 20)
nMillisecs = 1800
tDateTime = tDatetime + (nMillisecs / 1000) && add 1800 millisecs (1.8 secs) to the datetime
? tDateTime
cDateTime = cDateTime + PADL(nMillisecs, 3, "0"))
That's likely an SQLite datetime and it is that value, Mike.David Higgs said:A Field (BigInt) in a 3rd Party application contains a Value of 20170411165506093
Olaf Doschke said:VFP DATETIMES stop at seconds. If you need to preserve that, you need to store it separately. So use a datetime field for the main portion and an integer for milliseconds.
Olaf Doschke said:Are the milliseconds important at all? Does this database contain records in so fast succession, that you'd reorder the records
if you'd only query them into DBF with seconds precision?
Local lcDatabaseFilename, lcConnectionString, lnStatementHandle, ldDateTime
lcDatabaseFilename = "d:\temp\sqlite.db"
lcConnectionString = Textmerge("DRIVER=SQLite3 ODBC Driver;Database=<<lcDatabaseFilename>>;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;")
lnStatementHandle = Sqlstringconnect(lcConnectionString)
? lnStatementHandle
? SQLExec(lnStatementHandle,"create table datetimetest (id integer, inserted datetime)")
ldDateTime = Datetime()
? SQLExec(lnStatementHandle,"insert into datetimetest values (1,?m.ldDateTime)")
? SQLExec(lnStatementHandle,"Select * from datetimetest","crsTest")
? SQLDisconnect(lnStatementHandle)
Select crsTest
Browse
Local lcDatabaseFilename, lcConnectionString, lnStatementHandle, ldDateTime, lcDateTime
lcDatabaseFilename = "d:\temp\sqlite.db"
lcConnectionString = Textmerge("DRIVER=SQLite3 ODBC Driver;Database=<<lcDatabaseFilename>>;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;")
lnStatementHandle = Sqlstringconnect(lcConnectionString)
? lnStatementHandle
? SQLExec(lnStatementHandle,"create table biginttest (id integer, inserted bigint)")
ldDateTime = Datetime()
lcDateTime = Ttoc(ldDateTime,1)+"000"
? SQLExec(lnStatementHandle,"insert into biginttest values (1,"+lcDateTime+")")
? SQLExec(lnStatementHandle,"Select * from biginttest","crsTestBigInt")
? SQLDisconnect(lnStatementHandle)
Select crsTest
Browse
? SQLExec(lnStatementHandle,"insert into biginttest values (1,?m.lcDateTime)")
Olaf said:to write out more than 9 digits into a string is not a big problem, also not in VFP. It's up to the SQLite sql engine to turn that into a bugint. But I wonder why any application would use bigint as a datetime, SQLite has normal types...