parik
parik

Reputation: 2415

What is equivalent of strtotime in SQL?

I have a date in my first table with this format 2016-12-20 i need to compare it with another date in my second table with this format

 2016-12-21 18:40:22

in php i can change this format with

$date = date("Y-m-d", strtotime($date));

What is equivalent of strtotime in SQL or how can i compare 2 dates with different format in mysql?

i read this question and tried this

select STR_TO_DATE(date, '%y-%m-%d') from second_table;

but it returns NULL

Upvotes: 0

Views: 7249

Answers (1)

bugscoder
bugscoder

Reputation: 425

Date and Time Functions

you may need to use date_format()

Upvotes: 2

Related Questions