In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Sqlite : What is proper practice to store Date field ?

Xailer English public forum
Responder
Milan Mehta
Mensajes: 133
Registrado: Dom Dic 27, 2009 9:54 am

Sqlite : What is proper practice to store Date field ?

Mensaje por Milan Mehta »

Sqlite normally stores data as numeric value in the database. Xailer gives us the option to store the date value as numeric value (as default for sqlite) or store it date as character sting.
My question what is proper and prevalent method of storing Dates in Sqlite ? As Numeric Value or as Date character string ?
If we go for Date as character string, does it allow to operate on it like add or deduct days to it ?
Kindly guide and oblige.
Milan.
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5706
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Sqlite : What is proper practice to store Date field ?

Mensaje por jfgimenez »

Milan,
sorry for the delay.
> Sqlite normally stores data as numeric value in the
> database. Xailer gives us the option to store the date value
> as numeric value (as default for sqlite) or store it date as
> character sting.
>
> My question what is proper and prevalent method of storing
> Dates in Sqlite ? As Numeric Value or as Date character
> string ?
>
> If we go for Date as character string, does it allow to
> operate on it like add or deduct days to it ?
When Xailer added support for SQLite, several years ago, SQLite didn't
support dates as a native data type. So, we decided to do so, by adding
it as numeric julian-day values. That way, it's possible to add to or
substract days from any date value.
Later, SQLite added *limited* support for date values, but they decided
to do it by using strings in ISO format (yyyy-mm-dd).
Now, Xailer support both ways, by switching the property lDateAsString
in the datasource. However, only strings are supported by other SQLite
browsers.
BTW, I use to set lDateAsString to .T. in my own programs.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Milan Mehta
Mensajes: 133
Registrado: Dom Dic 27, 2009 9:54 am

Sqlite : What is proper practice to store Date field ?

Mensaje por Milan Mehta »

Thanks a lot. I too started working keeping lDateAsString := .T. and the result is encouraging.
Regards,
Milan.
Responder