Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
evansabres
Specialist
Specialist

Date String to Date

I have a date field called 'created_at' that comes into my application in the following format:

 

Mon Aug 26 14:04:21 +000 2019

 

How can I transform this in the script to show as a date in the format MM/DD/YYYY (from example above 8/26/2019

1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

instead of 'Mon Aug 26 14:04:21 +000 2019' place created_at

=Date(Date#(SubField(created_at,' ',2)&'-'&SubField(created_at,' ',3)
&'-'&SubField(created_at,' ',6),'MMM-DD-YYYY')
,'MM/DD/YYYY')

View solution in original post

6 Replies
dplr-rn
Partner - Master III
Partner - Master III

try something like below
=Date(Date#(SubField('Mon Aug 26 14:04:21 +000 2019',' ',2)&'-'&SubField('Mon Aug 26 14:04:21 +000 2019',' ',3)
&'-'&SubField('Mon Aug 26 14:04:21 +000 2019',' ',6),'MMM-DD-YYYY')
,'MM/DD/YYYY')
evansabres
Specialist
Specialist
Author

Where do I place my current field of 'created_at'

dplr-rn
Partner - Master III
Partner - Master III

instead of 'Mon Aug 26 14:04:21 +000 2019' place created_at

=Date(Date#(SubField(created_at,' ',2)&'-'&SubField(created_at,' ',3)
&'-'&SubField(created_at,' ',6),'MMM-DD-YYYY')
,'MM/DD/YYYY')

Vegar
MVP
MVP

Replace 'Mon Aug 26 14:04:21 +000 2019' in  @dplr-rn solution above with [created_at] like this

Date(Date#(SubField([created_at], ' ',2)&'-'&SubField([created_at] ,' ',3)
&'-'&SubField( [created_at], ' ',6),'MMM-DD-YYYY')
,'MM/DD/YYYY') as [Created at]

evansabres
Specialist
Specialist
Author

Thank you for your input. A follow-up question, would be if I wanted to get the Day of Week and Month from that field and create new fields called Day and Month, how would I do that in the script?

dplr-rn
Partner - Master III
Partner - Master III

You would use Day and Month function

Day(Datefield) as Day,

Month(Datefield) as Month,

 

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/DateA...