Yes. It doesn't have separate date 'type' fields. Everything is treated as characters and numbers.
However, they have date functions to use date strings.
For converting those strings, we could use DTOS() and STOD() as you have mentioned.
Long time ago, I tested SQLite too. At that time, I used to verify a string to be date, if it is in ANSI format, ie., yyyy-mm-dd. If it is, I would convert to date. See this sql function.
Code: Select all
function sql(dbo1,qstr)
local table := {}
local currow := nil
local tablearr := {}
local rowarr := {}
local datetypearr := {}
local numtypearr := {}
local typesarr := {}
local current := ""
local i := 0
local j := 0
local type1 := ""
table := sqlite3_get_table(dbo1,qstr)
if sqlite3_errcode(dbo1) > 0 // error
msgstop(sqlite3_errmsg(dbo1)+" Query is : "+qstr)
return nil
endif
stmt := sqlite3_prepare(dbo1,qstr)
IF ! Empty( stmt )
for i := 1 to sqlite3_column_count( stmt )
type1 := sqlite3_column_decltype( stmt,i)
do case
case type1 == "TEXT"
aadd(typesarr,"C")
case type1 == "INTEGER" .or. type1 == "REAL"
aadd(typesarr,"N")
endcase
next i
endif
sqlite3_reset( stmt )
if len(table) > 1
asize(tablearr,0)
rowarr := table[2]
for i := 1 to len(rowarr)
current := rowarr[i]
if typesarr[i] == "C" .and. len(alltrim(current)) == 10 .and. val(alltrim(substr(current,1,4))) > 0 .and. val(alltrim(substr(current,6,2))) > 0 .and. val(alltrim(substr(current,6,2))) <= 12 .and. val(alltrim(substr(current,9,2))) > 0 .and. val(alltrim(substr(current,9,2))) <= 31 .and. substr(alltrim(current),5,1) == "-" .and. substr(alltrim(current),8,1) == "-"
aadd(datetypearr,.t.)
else
aadd(datetypearr,.f.)
endif
next i
for i := 2 to len(table)
rowarr := table[i]
for j := 1 to len(rowarr)
if datetypearr[j]
rowarr[j] := CToD(SubStr(alltrim(rowarr[j]),9,2)+"-"+SubStr(alltrim(rowarr[j]),6,2)+"-"+SubStr(alltrim(rowarr[j]),1,4))
endif
if typesarr[j] == "N"
rowarr[j] := val(rowarr[j])
endif
next j
aadd(tablearr,aclone(rowarr))
next i
endif
return tablearr
I had used this code to create a nice project called LogiBase for logistics management. My client didn't want to install MySQL and wanted the database to be a single file. It is single user. Hence I had used SQLite and even now they are using the same.
This is the logo of the program.

- tanfama.jpg (21.55 KiB) Viewed 23767 times
This is a screenshot.

- screenshot.jpg (73.44 KiB) Viewed 23767 times