Reputation: 808
I have a table with a column called ID_PRT_TM. E.g,
SELECT TOP 10 ID
, ID_PRT_TM
FROM STG_OUT.example_table;
| ID | ID_PRT_TM |
+-------+-------------+
| 21018 | 641 |
| 20852 | 1056 |
| 24815 | 1442 |
| 20711 | 620 |
| 21554 | 1315 |
| 23341 | 936 |
| 21029 | 1056 |
| 20711 | 610 |
| 21555 | 918 |
| 20853 | 745 |
ID_PRT_TM is an integer that represents hours and minutes. For example, 641 is 6:41 AM and 13:15 is 1:15 PM. I want to add three hours to them but can't figure out how to do it.
Upvotes: 0
Views: 345
Reputation: 1269763
You can add 300:
select id_prt_tm + 300
If your hours are limited to 2400, then use fancier logic:
select (case when id_prt_tm < 2100 then id_prt_tm + 300
else id_prt_tm - 2100
end)
Or for more inscrutability:
select (id_prt_tm + 300) mod 2400
Upvotes: 1