Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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..
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
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
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..