« Return to Thread: Querying DATE column with date/time string.

Re: Querying DATE column with date/time string.

by Dan Kennedy-4 :: Rate this Message:

Reply to Author | View in Thread


On Dec 6, 2007, at 9:48 PM, Doug Van Horn wrote:

>
> Hi,
>
> I'm running into a problem with the database library in Django running
> against SQLite.  I'm trying to understand why the following happens:
>
> $ sqlite3 date_test
> SQLite version 3.4.2
> Enter ".help" for instructions
> sqlite> create table foo (d date null);
> sqlite> insert into foo (d) values ('2008-01-01');
> sqlite> select d from foo where d between '2008-01-01' and  
> '2008-01-31';
> 2008-01-01
> sqlite> select d from foo where d between '2008-01-01 00:00:00' and
> '2008-01-31 23:59:59.999999';
> sqlite> .quit
>
> In English, why does adding the 'time' portion to the between  
> clause not
> find the record?

Because according to the default collation sequence, strcmp(), the
string '2008-01-01 00:00:00' is larger than '2008-01-01'.

Dan.



>
>
> Thanks for any help or insights...
>
> Doug Van Horn
> --
> View this message in context: http://www.nabble.com/Querying-DATE- 
> column-with-date-time-string.-tf4956413.html#a14193493
> Sent from the SQLite mailing list archive at Nabble.com.
>
>
> ----------------------------------------------------------------------
> -------
> To unsubscribe, send email to sqlite-users-unsubscribe@...
> ----------------------------------------------------------------------
> -------
>


-----------------------------------------------------------------------------
To unsubscribe, send email to sqlite-users-unsubscribe@...
-----------------------------------------------------------------------------

 « Return to Thread: Querying DATE column with date/time string.