Link to home
Create AccountLog in
Avatar of bitt3n
bitt3n

asked on

Why does TIME_TO_SEC not convert time to seconds in the following statement?

What is the proper SQL syntax for getting the difference between two dates, and returning the result in seconds?

Specifically I am confused why the following syntax

SELECT TIME_TO_SEC( DATEDIFF( NOW( ) , SUBDATE( NOW( ) , INTERVAL 1 DAY ) ) )

returns 1, when that is the number of days and not the number of seconds in the date difference.
ASKER CERTIFIED SOLUTION
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of bitt3n
bitt3n

ASKER

great thanks