cancel
Showing results for 
Search instead for 
Did you mean: 

CURRENT_TIMESTAMP Microseconds resolution

francesco_alborghetti
Active Participant

Hi,

When I try this command from SQL console, I get a resolution till milliseconds (see attached screen).

Do you know if it is possible to increase the resolution till microseconds?

According to the documentation I should be able to get a detail of 7 decimal digits, but after the first three digits all others are 0.

Thanks

Francesco


SELECT TO_VARCHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.FF7') "to timestamp" FROM DUMMY

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Francesco,

> According to the documentation I should be able to get a detail of 7 decimal digits, but after the first three digits all others are 0.

Where did you find this info? I don't think CURRENT_TIMESTAMP or NOW() will return the resolution till microseconds. You cannot find this info from CURRENT_TIMESTAMP - SAP HANA SQL and System Views Reference - SAP Library or NOW - SAP HANA SQL and System Views Reference - SAP Library.

However it's true in SAP HANA that the format of TIMESTAMP is "YYYY-MM-DD HH24:MI:SS.FF7" You can find it from Data Types - SAP HANA SQL and System Views Reference - SAP Library

The format of TIMESTAMP and the result of CURRENT_TIMESTAMP are two different things.


CREATE COLUMN TABLE TT (T TIMESTAMP);

INSERT INTO TT VALUES (TO_TIMESTAMP('2014-10-28 14:00:00.1234567', 'YYYY-MM-DD HH24:MI:SS.FF7'));

INSERT INTO TT VALUES (CURRENT_TIMESTAMP);

SELECT TO_VARCHAR(T, 'YYYY-MM-DD HH24:MI:SS.FF7') "to timestamp" FROM TT;

Best regards,

Wenjun

francesco_alborghetti
Active Participant
0 Kudos

Hi Wenjun,

Thanks.

Maybe I have not been clear in my question: my point is as HANA timestamp supports timestamp resolution till 7 digits, is there any way to get such resolution in an HANA procedure?

As you said CURRENT_TIMESTAMP and NOW seem not to do it.

In my opinion documentation here is not very detailed, I would expect something more, also because if I try to handle the result of CURRENT_TIMESTAMP with a precision less than FF7 I get an error, so why should I consider CURRENT_TIMESTAMP with precision of 7 if the last 4 digits are blank?

Francesco

lbreddemann
Active Contributor
0 Kudos

NOW() and CURRENT_TIMESTAMP functions return the time with microseconds resolution.

And agreed, it would be good if the documentation would be explicit about this.

However, the datatypes work with up to seven digits precision.

Cheers,

Lars

Answers (1)

Answers (1)

former_member204338
Participant
0 Kudos

the question is still open.

lbreddemann
Active Contributor
0 Kudos

As this question has been marked as answered it would be best to create a new question with what you want to know.