Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

TIMESTAMP format issue in SAP HANA

mdruhul_amin
Explorer
0 Kudos

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
  • SAP Managed Tags:
1 ACCEPTED SOLUTION

pfefferf
Active Contributor
0 Kudos

What is stopping you to use the "HH24" format as target format in the final TO_NVARCHAR call?

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

Regards,
Florian

  • SAP Managed Tags:
2 REPLIES 2

pfefferf
Active Contributor
0 Kudos

What is stopping you to use the "HH24" format as target format in the final TO_NVARCHAR call?

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

Regards,
Florian

  • SAP Managed Tags:

0 Kudos

Hello Florian,

Thanks for prompt response.

It is working perfectly fine as per my requirement. I was not aware that we can use HH24 in final call. It's a nice learning experience for me.

Thanks alot.

Regards,

Ruhul

  • SAP Managed Tags: