Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser225
Contributor III
Contributor III

Question about Timeformart 12H to 24H

Hello All,

 

Can anyone please help to convert the 12h time format to 24h.

 

For example :

i  have data like 

7:00AM

12:00AM

1:45Pm 

4:00PM

i want to convert it to

7:00Am

12:00AM

13:45PM

16:00pm

 

Thanks in Advance

Labels (3)
1 Solution

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

ok - it is even more confusing now...

You need to understand what is Time() and Time#() function. Using TIme() function applies mask on the timestamp (so data must be in time/numerical) format already. Time#() function reads text string and converts it to time. 

So again...

First thing you need to establish is type of data you read. Is it numerical, date, timestamp .... or is it just text?

So If you have time stored as just text string you may want to use Time# function to read it and convert it to actual time. https://help.qlik.com/en-US/qlikview/May2023/Subsystems/Client/Content/QV_QlikView/Scripting/Interpr...

It would be like: Time#(SQL_StartTime,'hh:mmTT')  - that would read your text field and convert it to time which then you can format to your liking like: Time(Time#(SQL_StartTime,'hh:mmTT'), 'hh:mm')

note that hh:mm MUST be in lower case as "MM" stands for month and "mm" stands for minutes..

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

3 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

There is no such a thing like 13:00PM! It is either 1:00PM or 13:00.... which means that if you insist to have 13:00pm it will not be a time based function but text string. 

If it is only for display purposes you may just use regular time() function and concatenate it with text PM or AM. Using dual so it can still represent time...

Like:

Dual(Text(Time(yourtimefield,'HH:MM'))&If(Hour(yourtimefield)>=12,'PM','AM'),yourtimefield)

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Qlikuser225
Contributor III
Contributor III
Author

Thanks for the reply, 

 

I do not want to show as 13pm but I want to show 1 pm as 13:00.

i used the code you have provided, and it give me either AM or PM and it gives me blank result if i use without dual function like Time(SQL_StartTime,'HH:MM') 

 

Thanks

Srikanth

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

ok - it is even more confusing now...

You need to understand what is Time() and Time#() function. Using TIme() function applies mask on the timestamp (so data must be in time/numerical) format already. Time#() function reads text string and converts it to time. 

So again...

First thing you need to establish is type of data you read. Is it numerical, date, timestamp .... or is it just text?

So If you have time stored as just text string you may want to use Time# function to read it and convert it to actual time. https://help.qlik.com/en-US/qlikview/May2023/Subsystems/Client/Content/QV_QlikView/Scripting/Interpr...

It would be like: Time#(SQL_StartTime,'hh:mmTT')  - that would read your text field and convert it to time which then you can format to your liking like: Time(Time#(SQL_StartTime,'hh:mmTT'), 'hh:mm')

note that hh:mm MUST be in lower case as "MM" stands for month and "mm" stands for minutes..

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.