-3

there is a timepair table. It has columns :

start_pair  end_pair
08:30:00    09:15:00

I need to shift it by 30 min - how to do it? 8:30 becomes 9:00.

update

set start_pair = date(start_pair) + minute(30)
ERJAN
  • 23,696
  • 23
  • 72
  • 146

2 Answers2

2

I suppose you can use the DATE_ADD() function :

SET start_pair = DATE_ADD(start_pair, INTERVAL 30 MINUTE)
Titouan
  • 531
  • 4
  • 13
0

see https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_time-to-sec add 30 minutes(in seconds) and https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_sec-to-time

for example

set @t = '08:30:00';

select @t, sec_to_time(time_to_sec(@t) + (30*60));

+----------+----------------------------------------+
| @t       | sec_to_time(time_to_sec(@t) + (30*60)) |
+----------+----------------------------------------+
| 08:30:00 | 09:00:00                               |
+----------+----------------------------------------+
1 row in set (0.00 sec)
P.Salmon
  • 17,104
  • 2
  • 12
  • 19
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Barmar Feb 19 '21 at 16:04