Radcon Entec <radconen...@yahoo.com>
wrote:
> I am trying to write a simple applicaton in C# that will remove all
> data older than 30 days from an SQLite table. However, my application
> is removing all data, not just the old data.
>
> Before I run my query, the value_timestamp field of my table contains:
>
> 2009-05-07 17:00:43
>
> My query is:
>
> delete from trend_data where datetime(value_timestamp) < '4/7/2009
> 12:37:32 PM'

Realize that SQLite doesn't have a dedicated type for dates or times. 
'4/7/2009 12:37:32 PM' is simply a string literal, and your query 
performs the usual string comparison. Since '2' is less than '4', all 
dates in your table satisfy the condition.

Now, if you represent your cut-off date as '2009-04-07 12:37:32' then 
string comparison would correctly order timestamps, too.

Igor Tandetnik 



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

Reply via email to