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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Datetime conversion

Hello Experts,

I want to convert timestamp from mm/dd/yyyy hh:mi:ss am/pm(4/17/2017 7:22:43 AM) format to yyyy-mm-dd hh:mm:ss format(2017-04-17 06:48:46.00).

Can anyone help me on this conversion.

Regards,

Kumar

1 Solution

Accepted Solutions
asgardd2
Creator III
Creator III

TimeStamp(Timestamp#('4/17/2017 07:22:43 AM','M/D/YYYY h:m:s TT'),'YYYY-MM-DD hh:mm:ss.00')

View solution in original post

7 Replies
tresesco
MVP
MVP

How do you get  - 06:48:46.00 from 7:22:43 AM ?

swuehl
MVP
MVP

In general, read your timestamp in resulting in a dual value:

Get the Dates Right

Why don’t my dates work?

If needed, use an interpretation function like TimeStamp#()

Then you can format your values like your request using formatting functions like TimeStamp()

The two format codes for your samples are

'MM/DD/YYYY hh:mm:ss TT'

resp.

'YYYY-MM-DD hh:mm:ss'

Note that minutes need a lower case 'm' and month a upper case 'M'.

Anonymous
Not applicable
Author

Hi Tresesco,

Thanks for your reply.

I mean that the format should be 06:48:46.00.

Can you help me how to trim trim that AM/PM part and convert to my YYYY-MM-DD hh:min:ss format

Regards,

Kumar

Anonymous
Not applicable
Author

Hi Stefan,

Thanks for your answers.

Actually I am trying to use these in my script. Like

Let vDate=Timestamp#(NOW(), 'YYYY-MM-DD hh:mm:ss')

and that variable value i am trying to compare database timestamp value as in the format like 2017-04-17 06:48:46.00.

But it is throwing error.

Regards,

Kumar

asgardd2
Creator III
Creator III

TimeStamp(Timestamp#('4/17/2017 07:22:43 AM','M/D/YYYY h:m:s TT'),'YYYY-MM-DD hh:mm:ss.00')

swuehl
MVP
MVP

I assume and hope your database timestamp values are in fact numbers. You should be able to compare just numbers then (Now() also returns a number / dual value).

Anonymous
Not applicable
Author

Thanks a lot for your help Aleksadrov...