T
T
tincap2015-08-14 20:05:09
MySQL
tincap, 2015-08-14 20:05:09

Date Time. How to determine that the date is greater and the time is less?

There is a column of type DATETIME. Stores the date and time in the form yyyy-MM-dd HH:mm:ss
Is it possible to do the following without dividing the time and date into separate columns:
display those rows where the date is greater than 2015-09-22 and the time is less than 15:00: 00

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2015-08-14
@tincap

SELECT *
FROM table
WHERE
DATE_FORMAT(datefield, '%Y-%m-%d') > '2015-09-22' AND
DATE_FORMAT(datefield, '%H:%i:%s') < '15:00:00'

D
Dmitry, 2015-08-14
@thewind

Look at mysql cast

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question