Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor II
Contributor II

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
Highlighted

Try TimeStamp() instead of TimeStamp#()

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

Highlighted
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

Highlighted
Contributor II
Contributor II

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