Get data according to Mysql date

Asked

Viewed 97 times

2

I need to provide the option to view the data according to an X time determined by the user, for example

I want the data from 01/03/2011 until 25/12/2014

How can I do this with Mysql? How do I need to mount the table so everything can go well?

  • 1

    I undid the closure and the exclusion, I realized it’s not quite duplicate that other.

  • But it’s still a little wide. Your question is only in relation to the database?

  • Yes, how can I get from date X to date Y (query) and how to mount the table (what type to use etc..)

1 answer

2

If you have a 'column' with the type DATE, may use the following:

SELECT * FROM table WHERE coluna > '2011-03-01' AND coluna < '2014-12-25'

If 'column' is in DATETIME may use the following:

SELECT * FROM table WHERE coluna > '2011-03-01 00:00:00' AND coluna < '2014-12-25 00:00:00'

Since it was not specified how your database is, this could help. Logically, can be used the TIMESTAMP or TIME, but, just adapt.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.