0

I have this scheme:

--------------------------
| ID | data  | timestamp |
--------------------------

how i can make a query to show only today values? I now i need to use the BETWEEN statement, any idea?

2
  • What format is the timestamp? is it a MySQL DATETIME or a Unix timestamp? Commented Mar 11, 2011 at 20:42
  • solved, I've been working with timestamp like varchar. Commented Mar 11, 2011 at 21:22

2 Answers 2

1
SELECT   *
FROM     mytable
WHERE    DATE(timestamp) = CURDATE()

Or so I think.

Sign up to request clarification or add additional context in comments.

5 Comments

I've inserted some bulk data into my db, but that query doesn't work.
@greenbandit: What's the datatype of "timestamp"?
varchar, since your last respond... seems like i need to change it.
@greenbandit: I would agree, especially for indexing purposes. But you can cast/convert it to a datetime for comparison, though pretty slow.
@greenbandit: glad to hear. ;-)
1
select ID, date, timestamp
from yourtable
where DATE(`timestamp`) = CURDATE()

2 Comments

no rows? or rows filled with blanks? Obviously, check if you've got any records that have today's date for the timestamp.
thanks, solved, bad field type, set up to timestamp and works like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.