Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
TimeStamp(Timestamp#('4/17/2017 07:22:43 AM','M/D/YYYY h:m:s TT'),'YYYY-MM-DD hh:mm:ss.00')
How do you get - 06:48:46.00 from 7:22:43 AM ?
In general, read your timestamp in resulting in a dual value:
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'.
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
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
TimeStamp(Timestamp#('4/17/2017 07:22:43 AM','M/D/YYYY h:m:s TT'),'YYYY-MM-DD hh:mm:ss.00')
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).
Thanks a lot for your help Aleksadrov...