Click to See Complete Forum and Search --> : Trouble with Date Query,


SeanieC
07-17-2006, 07:09 AM
I'm having trouble running a query and I was wondering if anyone could just show me what I am doing wrong.

I have a table in this case its called tbltimes, inside my table I have a column called time stamp.

The timestamp is in the format of

dd/mm/yyyy hh:mm:ss (not sure if thats the right query indentifiers)

Well I need to retrieve information of from the last 15 days of the current day and instead of constantly updating the query with the current date I wanted the query to use the now() & CurrentDate() command but 15 days ago.

I tried

SELECT * FROM tbltimes WHERE timestamp >= CurrentDate() -15;

but it didn't work, I guess it was a long shot anyways,

Well thanks for anyone who can help!

Sean Cansdale.

sridhar_423
07-17-2006, 07:23 AM
works in SQL..
select * from tbltimes WHERE sysdate-to_date(to_char(timestamp,'dd/mm/yyyy hh24:mi:ss '),'dd/mm/yyyy hh24:mi:ss ') >= -15;

dont know if timestamp can be subtracted directly from sysdate

SeanieC
07-17-2006, 08:39 AM
I will give it a go, thanks mate.

SeanieC
07-17-2006, 11:30 AM
Nope, Didn't work, any other ideas?

Is it even possible?! lol

mattyblah
07-17-2006, 11:46 AM
look into the datediff function. That should do the trick.

SeanieC
07-17-2006, 11:49 AM
Roger, Roger. Thanks.

SeanieC
07-17-2006, 11:59 AM
Uhh, wouldn't that return an integer representing the difference of days between two dates? Rather then returning all dates that meet the query?

I'm confused now...

chazzy
07-17-2006, 02:03 PM
no, date diff returns a date, not an int. what server do you use?

SeanieC
07-17-2006, 02:35 PM
Hi,

Well the thing is I was making an enquiry for someone else, I think they are using an access database and ASP. If you have a solution that would be fantastic! If not don't loose sleep over it :cool:

Thanks!