On 5/19/2011 7:54 PM, Sandy Bottom wrote:
> My objective is a query which lists events and calculates the number of days
> to the event e.g:
>
>
> Name Days to Event
> ---------        -------------
> Christmas 40
>
>
> The event table might look something like:
>
> create table event (
>    name varchar (50),
>    when text (20));
>
>
> (Regarding storing date values in a text field, I will use whatever datatype
> best facilitates the calculation.)
>
>
> What would an 'insert' statement for this table look like? E.g.
>
> insert into event values ('Christmas', ... );

insert into event values ('Christmas', '2011-12-25');

> What would the select statement which calculates the 'Days to Event' column
> look like? E.g.
>
> select name, ... from event;

select name, julianday(when) - julianday('now', 'start of day') from event;

See http://sqlite.org/lang_datefunc.html
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to