mysql query to track the dateline (UNIX_TIMESTAMP)

Posted on 2008-11-06
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 59

    Accepted Solution

    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

    Thanks Buddy... It worked

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
    This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now