Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date filtering

Status
Not open for further replies.

riluve

Technical User
Mar 11, 2005
78
US
I am trying to filter by a timestamp, without using a 'raw' time stamp in the filter. if I do this:
SELECT count(*)
FROM table
WHERE timestamp > '2006-01-01'

I simply get every record, but if i use the raw timestamp:

SELECT count(*)
FROM table
WHERE timestamp > 1136073600

I get the expected count.
 
Oh, sorry - so the question is, what is wrong with the first example? I dont want to have to look up the proper timestamp everytime I need to run the query.
 
depends on your database

this is the ANSI SQL forum, and i don't think there's a standard SQL function for that

if you were, by some remote chance, using MySQL, then there's a function called FROM_UNIXTIME that does exactly what you need

:)

r937.com | rudy.ca
 
HA - great yeah I am using MySQL thank you very much. I noticed I forgot some detail after I posted, but it wont let me edit it.

And yeah - i dont really know where ANSI SQL stops and MySQL begins. Thnx again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top