Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
stekol61
Creator
Creator

Timestamp to hour

Hi!

I have  a field with timestamp data in a Sense app ( hh:mm:ss.)

How can do to change this from e.g '73:58:54' to '73' ?

01:54:43
01:55:47
73:58:54
289:34:52
361:05:27
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Timestamps are actually numbers at the back end. That is how you see a timestamp value is different as a number at the back end. For example, if you see timestamp as 1:00:00 (hh:mm:ss) format is actually a fraction and is 1/24. Also this is also possible that it could be n+1/24,( where n is an integer) when you just try to format and show time part from a date+timestamp value.

Hence, it would be imperative to understand what exactly you are going to perform with the value '73' from  '73:58:54'. Because 73 could be shown as 73 a time (actually a fraction) could also be shown as 73 (actually the integer 73) - ways are there. Therefore, let know what-next (if any) to do with this '73' or just showing '73' is fine.

 

For just showing : Interval(Timestamp#( '73:58:54', 'hh:mm:ss'), 'hh')                

For performing operation next on it (like 73+1=4) : SubField('73:58:54', ':',1)

View solution in original post

3 Replies
Somasundaram
Creator III
Creator III

hi,

 

you can use

hour(time field) as hour


-Somasundaram

If this resolves your Query please like and accept this as an answer.
stekol61
Creator
Creator
Author

I tried that but it doesn't work.
Probably because the field is a string
tresesco
MVP
MVP

Timestamps are actually numbers at the back end. That is how you see a timestamp value is different as a number at the back end. For example, if you see timestamp as 1:00:00 (hh:mm:ss) format is actually a fraction and is 1/24. Also this is also possible that it could be n+1/24,( where n is an integer) when you just try to format and show time part from a date+timestamp value.

Hence, it would be imperative to understand what exactly you are going to perform with the value '73' from  '73:58:54'. Because 73 could be shown as 73 a time (actually a fraction) could also be shown as 73 (actually the integer 73) - ways are there. Therefore, let know what-next (if any) to do with this '73' or just showing '73' is fine.

 

For just showing : Interval(Timestamp#( '73:58:54', 'hh:mm:ss'), 'hh')                

For performing operation next on it (like 73+1=4) : SubField('73:58:54', ':',1)