0

I have to find the difference in two dates (dates have to converted from string to date format). I am using the following mysql query

SELECT DATEDIFF
(
        (SELECT STR_TO_DATE(create_date, '%e %b %Y  %k:%i') AS create_date FROM booking) AS date1
        ,
        (SELECT STR_TO_DATE(start_date, '%e %b %Y  %k:%i') AS start_date FROM booking) AS date2
) diff 

Individually the inner queries work successfully. The date format is correctly converted for example from 5 Mar 1985 2:33 to 1985-03-05 02:33:00

Himanshu
  • 31,810
  • 31
  • 111
  • 133
user1369905
  • 663
  • 2
  • 7
  • 12

1 Answers1

2

What is stopping you from

SELECT
  DATEDIFF( 
    STR_TO_DATE(create_date, '%e %b %Y  %k:%i'),
    STR_TO_DATE(start_date, '%e %b %Y  %k:%i')
  ) AS diff
FROM booking
Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92