Skip to content
Advertisement

how to add 30 minutes in last value of return query using oracle?

My query is

which produces:

i want above result as

Advertisement

Answer

Assuming you are storing the times in a DATE data type (which always has year, month, day, hour, minute and second components) then add an INTERVAL literal to the maximum value from the table:

or add a fraction of a day:

Output:

| CLASS_TIME          |
| :------------------ |
| 2019-12-16 02:00:00 |
| 2019-12-16 02:30:00 |
| 2019-12-16 03:00:00 |
| 2019-12-16 03:30:00 |
| 2019-12-16 04:00:00 |
| 2019-12-16 04:30:00 |

If your times are stored as strings then convert them to a date, add 30 minutes and then convert back to a string:

Output:

| CLASS_TIME |
| :--------- |
| 02:00 AM   |
| 02:30 AM   |
| 03:00 AM   |
| 03:30 AM   |
| 04:00 AM   |
| 04:30 AM   |

db<>fiddle here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement