Skip to Content
0
Feb 09, 2017 at 11:36 AM

TIMESTAMP format issue in SAP HANA

16336 Views

Hello,

We have a table in Hana where data is coming from ECC via SLT system and there is a column which is storing the TIMESTMP as YYYYMMDDHHMMSS format So, I want to subtract 5 minutes from above TIMESTAMP to achieve this am using add_seconds function by converting it first to TIMESTAMP format later again converting it to string format as YYYYMMDDHHMMSS. I am getting the desired result but I want to keep my TIMESTAMP in 24hrs Format like If I have a TIMESTAMP 20170209143012 in this format then it should need be the same but while doing conversion it is coming as 20170209022512 here TO_TIMESTAMP function converting it to PM and AM format In this case 14 converted to 2 as PM

So, I don't want to change my format it should be in 24hrs format only. I have run the simple SQL on DUMMY to illustrate this example your kind help will highly appreciated.

SELECT to_nvarchar(ADD_seconds ( TO_TIMESTAMP (to_nvarchar( '20170209143012', 'YYYY-MM-DD HH24:MI:SS'),  'YYYY-MM-DD HH24:MI:SS'), -60*5),'YYYYMMDDHHMISS') "TIMESTAMP" FROM   dummy