On 1/23/2012 12:51 PM, dotolee wrote:
i'm new to sqlite... and relatively new to php.  just wondering what the best
way is to store and compare dates.
right now i have something like this in my php code:
        $curr_date_time = strftime('%Y-%m-%d %H:%M:%S');
i'm inserting this into a field in the database that has been defined as
type TEXT because from what i read, sqlite does not have a date datatype.
but question is how can i write a select statement that will sort by date?

select * from MyTable order by MyDateColumn;

With this format, alphabetical order happens to match calendar order. No additional magic required.

the sql i have right now is not working because it's not treating the field
as a true date...

Show the SQL you have right now, sample data, and the query results. Explain how actual results differ from your expectations.

i want to do something like:

select field1, field2, updated from myhistory group by field1 order by
updated desc

This query doesn't make much sense. Suppose you have ten rows with field1='X', but with different values of field2 and updated. GROUP BY clause will produce one row representing this group, where field1='X', while field2 and updated would be taken from some random row in the group (not even necessarily the same one). Is this what you had in mind?
--
Igor Tandetnik

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

Reply via email to