I have a table with different dates and one of them is separated in 3 fields:
PassDay, PassMonth, PassYear.
I want to compare these dates with an other datetime orig_date so what I did is
select `orig_date`, CONCAT_WS('-',`PassYear`,`PassMonth`,`PassDay`) as `pass_expiration` where `pass_expiration` < `orig_date`;
The problem is that the month is stored as a month name (January) and not a number (01), so my result for pass_expiration is 2013-April-15 for example.
Is there a way to transform this (2013-April-15) to a regular datetime directly from the query?
You want
str_to_date:Also, as a note, you can’t reference a computed column in the
whereclause. Only in theorder byclause (whereis a predicate that’s used to filter results from the table;order byis run after the column set is calc’d).