Convert 12 Hour Time Format into 24 Hour Time Format in Hana
The requirement is to convert 12 hour format time into 24 hour format.
We are saving Time in a column in 12 Hour format but in the output we need to show the time in 24 Hour format.
Example below –
|Source Time Format||Expected Output|
|11:03:00 PM||23:03:00 PM|
|11:03:00 AM||11:03:00 AM|
Solution 1 –
First solution for above requirement is to use Hana Sql Code as below.
SELECT TO_NVARCHAR(TO_TIME('11:03:00 PM'), 'HH24:MI:SS AM') AS "TIME_12HH", TO_NVARCHAR(TO_TIME('11:03:00 AM'), 'HH24:MI:SS AM') AS "TIME_24HH" FROM DUMMY;
Solution 2 –
If we need to get the output in 24 Hour time format in Hana view then we can use in built function “Secondtime“.
Hope this will be helpful..!
Please do let me know if there is any other workaround available.
Thanks & Happy Learning!