"Çaðlar Orhan" <cagla...@gmail.com> schrieb im
Newsbeitrag
news:677fef480912130642u5ed971b2r2c9cbec17771e...@mail.gmail.com...
> I am using SQLite for my little HTA application with
> vbscript.
> Everything is ok but in my sql query date format gets
> wrong records. SQLite uses YY-MM-DD
Normally it should be: YYYY-MM-DD

> i am querying with DD-MM-YY what should i do?
You are aware of the VBScript Format(...) function?
Just get your input right, before you feed it to the
SQLite-engine in your concatenated SQL-command-
string...

Dim D
D = CDate(Now) 'ensure a Variant-DateType within 'D'

MsgBox Format(D, "'yyyy\-mm\-dd'")
will give you the content of the Date-Variable as:
'YYYY-MM-DD'

and if your SQLite-Table really contains the dates in YY-MM-DD,
then:
MsgBox Format(D, "'yy\-mm\-dd'")
will give you:
'YY-MM-DD'
appropriately (in both cases already including the quote-signs).

Then your SQL-string-construct could look like this for example:
(assuming D1 and D2 represent Date-Variables and define an interval).
SQL = "Select * From Table Where DCol Between " & _
             Format(D1, "'yy\-mm\-dd'") & " AND " & _
             Format(D2, "'yy\-mm\-dd'")

Or define a Const for the above shown Format-Def-
Stringliteral for the second Parameter of the Format-Function.

Nonetheless better to use a command-object for that task, in
case your current COM-wrapper has built-in support for that.

Olaf Schmidt



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to