Transmogrify into date from multiple columns
Posted
by Dave Jarvis
on Stack Overflow
See other posts from Stack Overflow
or by Dave Jarvis
Published on 2010-05-04T23:25:00Z
Indexed on
2010/05/04
23:28 UTC
Read the original article
Hit count: 212
What is a better way to program the following SQL:
str_to_date(
concat(convert(D.DAY, CHAR(2)),
'-',
convert(M.MONTH, CHAR(2)),
'-',
convert(M.YEAR, CHAR(4))),
'%e-%m-%Y' ) as AMOUNT_DATE
I want to convert the columns D.DAY
, M.MONTH
, and M.YEAR
to a date field using MySQL. The above works, but seems much more complicated than it needs to be. (If there's an ANSI SQL way to do it, that would be even better.)
Thank you!
© Stack Overflow or respective owner