0

How can I add two hours to the mysql field of TIME type? This problem seems unsolvable to me. I have tried:

1)

select TimeStart + interval 2 hour
from table

returns null

2)

select addtime(TimeStart, interval 2 hour)
from table

returns error

3)

select convert_tz(TimeStart, 'GMT', 'CEST')
from table

(because the 2 hour difference was due to messed up timezones, so this is another way to correct it)

also returns null!

4)

select date_add(TimeStart, interval 2 hour)
from table

also returns null!

I start to curse mysql... would be easy with DATETIME type, but really not very easy to work with the TIME type.

Community
  • 1
  • 1
Tomas
  • 57,621
  • 49
  • 238
  • 373

2 Answers2

2

Sorry I just figured it out!

addtime(TimeStart, '2:00')

Not very intuitive and consistent with the INTERVAL thing though!

Tomas
  • 57,621
  • 49
  • 238
  • 373
-1
SELECT HOUR(TimeStart)+2 FROM table

gives you the 2 hour increment.

Sablefoste
  • 4,032
  • 3
  • 37
  • 58