V
V
viktorross2020-02-27 00:13:59
MySQL
viktorross, 2020-02-27 00:13:59

How to get only date from DATETIME mysql?

Hello, please tell me, something is not working the request, I need to get the date without time from the database and compare it with the current date on the server, I make the following request

SELECT DATE(`registration_date`) FROM  `class_users`  WHERE  `registration_date` =  '2020-02-26' AND  `id` =  '7260'


however, it returns an empty result, the registration_date field is in datetime format,

although it should accurately display only 1 result in which both id and registration_date match,

please tell me how else you can try

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nokimaro, 2020-02-27
@viktorross

SELECT DATE(`registration_date`) FROM  `class_users`  
WHERE DATE(`registration_date`) =  '2020-02-26' AND  `id` =  '7260'

SELECT DATE(`registration_date`) FROM  `class_users`  
WHERE `registration_date` LIKE '2020-02-26%' AND  `id` =  '7260'

A
Alexander, 2020-02-27
@zkelo

DATE_FORMAT()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question