Re: [sqlite] subtracting days from two dates

2006-06-27 Thread Dennis Cote

mithin wrote:

Hi,

I want to find if the difference between the days of two dates is less than
or greater than some number. The year is not in the picture and it can be
anything. I gave the following query but it is not working.

SELECT * FROM date_details WHERE (date(date_details.value,%j) -
date('now',%j) < 30)

Can someone pls help me?
Thanks a lot.
  

Try this:

   SELECT * FROM date_details 
   WHERE abs(strftime(date_details.value,'%j') -
	strftime('now','%j')) < 30 



HTH
Dennis Cote


Re: [sqlite] subtracting days from two dates

2006-06-27 Thread Jay Sprenkle

On 6/27/06, mithin <[EMAIL PROTECTED]> wrote:


Hi,

I want to find if the difference between the days of two dates is less than
or greater than some number. The year is not in the picture and it can be
anything. I gave the following query but it is not working.

SELECT * FROM date_details WHERE (date(date_details.value,%j) -
date('now',%j) < 30)

Can someone pls help me?



From the wiki:


http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions

Compute the number of seconds between two dates:
 SELECT julianday('now')*86400 - julianday('2004-01-01 02:34:56')*86400;

maybe this:

SELECT * FROM date_details
WHERE julianday(value) - julianday('now') < 30






--
SqliteImporter and SqliteReplicator: Command line utilities for Sqlite
http://www.reddawn.net/~jsprenkl/Sqlite

Cthulhu Bucks!
http://www.cthulhubucks.com