Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jerryhelms2017
Partner - Contributor III
Partner - Contributor III

Converting from AM/PM time to 24 hour time

My date fields are separated and the first step is to combine them.  The code below works successfully.

EventDate,

StartTimeHour as ALT_StartTimeHour,

     StartTimeMinute as ALT_StartTimeMinute,

     StartTimeAM_PM as ALT_StartTimeAM_PM,

    

      timestamp#(EventDate & ' ' & num(StartTimeHour,'00')

      & ':' & num(StartTimeMinute,'00')

        & ' ' & StartTimeAM_PM,'MM-DD-YYYY h:mm TT' ) as ALT_EventDate,

     

The output is in the AM/PM format, but I need the 24 hour format.

date2.PNG

In a preceding load I have tried various timestamp and date functions.  For example, the code below returns a null value.

  timestamp#(ALT_EventDate,'MM-DD-YY h:mm') as ALT_EventDate2,

3 Replies
sunny_talwar

Try TimeStamp() instead of TimeStamp#()

TimeStamp(ALT_EventDate,'MM-DD-YY h:mm') as ALT_EventDate2,

YoussefBelloum
Champion
Champion

Hi,

referring to this link:

Convert 12 Hour to 24 Hour Timestamp

try Manish and Tresesco suggestions

TimeStamp(Timestamp#(ALT_EventDate,'DD/MM/YYYY hh:mm:ss TT'),'DD/MM/YYYY hh:mm:ss') as ALT_EventDate


OR


SET TimestampFormat='DD-MM-YYYY hh:mm:ss[.fff]';

TimeStamp(Timestamp#(ALT_EventDate, 'DD/MM/YYYY hh:mm:ss TT')) as ALT_EventDate

jerryhelms2017
Partner - Contributor III
Partner - Contributor III
Author

I think the issue was that I was using '-' as a date separator as opposed to '/'.  The solution from Youssef works.