Learn how to a build a cloud-first strategyRegister Now


mysql query to track the dateline (UNIX_TIMESTAMP)

Posted on 2008-11-06
Medium Priority
Last Modified: 2010-04-21
Hello Experts,

I have a mysql database where date and time is stored in the dateline format (UNIX_TIMESTAMP).  I need a sql query which should pull up the data entered between two given timeline.

For ex:
In order to search the data which is entered today i use the following sql query:
SELECT * FROM table WHERE dateline > UNIX_TIMESTAMP(CONCAT(CURDATE(), ' ', '00:00:00'))

Now what i am looking for is a sql query to pull up the data entered between two given dates.


Question by:Shiva_Kumar
LVL 60

Accepted Solution

Kevin Cross earned 1400 total points
ID: 22898063
Hello Shiva_Kumar,

I would use a between statement:
SELECT * FROM table WHERE dateline BETWEEN UNIX_TIMESTAMP('2008-10-06 00:00:00') AND  UNIX_TIMESTAMP('2008-11-06 23:59:59');


I would use two statements:
SELECT * FROM table WHERE dateline > UNIX_TIMESTAMP('2008-10-06 00:00:00') AND dateline < UNIX_TIMESTAMP('2008-11-07 00:00:00');



Author Closing Comment

ID: 31514029
Thanks Buddy... It worked

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question