Convert 12 Hour Time Format into 24 Hour Time Format in Hana

Requirement

The requirement is that, 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",
TO_NVARCHAR(TO_TIME('11:03:00 AM'), 'HH24:MI:SS AM') AS "TIME_1"
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“.

Secondtime

Hope this will be helpful..!

Please do let me know if there is any other workaround available.

Thanks & Happy Learning!