asim asim - 21 days ago 6
MySQL Question

formatting concatenated string to date format in one query

I have two queries and I dont know how to bring them together in one query.

First query:

SELECT CONCAT(D_STRING, T_STRING) FROM TAB_CRU WHERE BILD_ID = '05985957'


Returns this:
08.11.2011231459

Second query:

SELECT DATE_FORMAT(STR_TO_DATE('5.16.2011231459', '%c.%e.%Y%H%i'), '%d.%m.%Y/%H.%m')


Returns this:
08.11.2011/23.14

The result of the second query is what I would like to have at the end

Thx

Answer

Try like this,

SELECT  
DATE_FORMAT(STR_TO_DATE(CONCAT(D_STRING, T_STRING), '%c.%e.%Y%H%i'), '%d.%m.%Y/%H.%m') 
FROM TAB_CRU 
WHERE 
BILD_ID = '05985957'