That was a quick response!

The Date is being stored as yyyy-mm-dd. Note the "Format$(Date,
'yyyy-mm-dd') as Date" that assures this.

And I have it in this format for sDateTemp so that they would compare the
same.

But it does not work.

So what am I doing wrong?

Thanks.

Rick
 
 

#>-----Original Message-----
#>From: sqlite-users-boun...@sqlite.org 
#>[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov
#>Sent: Monday, August 03, 2009 1:25 PM
#>To: General Discussion of SQLite Database
#>Subject: Re: [sqlite] Date Comparisons SQL
#>
#>> How do you properly do a Date comparison in SELECT so that the only 
#>> rows returned are those that do not exceed the date found in my 
#>> sDateTemp variable?
#>
#>As a simple string comparison. You made it perfectly right 
#>except that your Date field should be stored in a format 
#>'yyyy-mm-dd' in database.
#>Without it comparison will not work.
#>
#>Pavel
#>
#>On Mon, Aug 3, 2009 at 2:19 PM, Rick 
#>Ratchford<r...@amazingaccuracy.com> wrote:
#>> This works:
#>>
#>> SQLString = "SELECT Format$(Date, 'yyyy-mm-dd') as Date, 
#>Year, Month, 
#>> Day, Open, High, Low, Close, DayNum, 0 as IsSwingTop1, 0 as 
#>> IsSwingBtm1, 0 as IsSwingTop2, 0 as IsSwingBtm2, Null as 
#>Delta1, Null 
#>> as Delta2, 0 as Offset1, 0 as Offset2 FROM [" & sTable & "] 
#>GROUP BY 
#>> Year, Month, Day"
#>>
#>>
#>> This does not:
#>>
#>> SQLString = "SELECT Format$(Date, 'yyyy-mm-dd') as Date, 
#>Year, Month, 
#>> Day, Open, High, Low, Close, DayNum, 0 as IsSwingTop1, 0 as 
#>> IsSwingBtm1, 0 as IsSwingTop2, 0 as IsSwingBtm2, Null as 
#>Delta1, Null 
#>> as Delta2, 0 as Offset1, 0 as Offset2 FROM [" & sTable & "] 
#>WHERE Date 
#>> < " & sDateTemp & " GROUP BY Year, Month, Day"
#>>
#>> The difference is that I want the second statement to only retrieve 
#>> records (rows) that do not exceed the date listed in sDateTemp.
#>>
#>> I've converted the local date format to "yyyy-mm-dd" in sDateTemp 
#>> before using it in this SQL statement. But that didn't seem 
#>to solve 
#>> the problem. I'm still getting a single blank record.
#>>
#>> How do you properly do a Date comparison in SELECT so that the only 
#>> rows returned are those that do not exceed the date found in my 
#>> sDateTemp variable?
#>>
#>> Thanks.
#>> Rick
#>> _______________________________________________
#>> sqlite-users mailing list
#>> sqlite-users@sqlite.org
#>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
#>>
#>_______________________________________________
#>sqlite-users mailing list
#>sqlite-users@sqlite.org
#>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
#>
#>


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

Reply via email to