Reputation: 17
Hi want to subtract 1 min from current time in my sql i used following query but it is showing null
query
SELECT curtime() - INTERVAL '00:00:30' SECOND
what should i do to get my result
Any help will be appreciated
Upvotes: 1
Views: 3114
Reputation: 1264
Try this
SELECT TIMEDIFF(curtime(),'00:00:30');
In Seconds
SELECT TIME_TO_SEC(TIMEDIFF(curtime(),'00:00:30'));
Or Static One
SELECT TIME_TO_SEC(TIMEDIFF('00:01:00','00:00:30'))
Upvotes: 2
Reputation: 64476
For minute you can do so
SELECT curtime() - INTERVAL 1 MINUTE
Another one will be something like below but its return type will string no time
SELECT
SUBSTRING_INDEX(
NOW() - INTERVAL 1 MINUTE
,' ',-1)
Upvotes: 0