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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikBeginner1
Creator
Creator

Text to Date Format NULL when converting

Hello,

this may be simple,

QlikBeginner1_0-1646389354038.png

I have two date fields, one which is text (DateTermIssued) and one which is the renewal date.

I am trying to get a duration of the two dates, but I am unable to format the DateTermIssued field to be a date field?

QlikBeginner1_1-1646389413806.png

I have tried many different date functions to try and convert it, but unable to do so?

Date(Floor(Date#( DateTermIssued1, 'MMM DD YYYY HH:MM:tt'),'DD/MM/YY')) as an example, just gives a null, can you see what I am doing wrong, 

Jun 1 2021 12:00AM

This is how the date term issued field is showing the data in excel. MMM DD YYY HH:MM:tt

any help would be greatly appreciated,

 

Labels (1)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

A bracket was misplaced, and it needs to be D and not DD.

Try
Date(Floor(Date#(DateTermIssued1, 'MMM D YYYY hh:mmTT')),'DD/MM/YY')
Date#(Trim(Left(DateTermIssued1,Index(DateTermIssued1,' ',3)-1)), 'MMM D YYYY')
Date#(Trim(Subfield(DateTermIssued1,':',1)), 'MMM D YYYY hh')

View solution in original post

5 Replies
hic
Former Employee
Former Employee

Try this in the script:

Date(Floor(Date#( DateTermIssued1, 'MMM DD YYYY hh:mmTT'),'DD/MM/YY'))

Note that hours and minutes must be in lower case, and TT must be in upper case.

hic
Former Employee
Former Employee

A second alternative is
Date#(Left(DateTermIssued1,Index(DateTermIssued1,' ',3)-1), 'MMM DD YYYY')

QlikBeginner1
Creator
Creator
Author

Thanks Henric,

Not working correctly, first formula NULL and the second formula gives me a result, but when i try to Format this into a date it nulls too,

QlikBeginner1_0-1646391243861.pngQlikBeginner1_1-1646391273261.png

 

hic
Former Employee
Former Employee

A bracket was misplaced, and it needs to be D and not DD.

Try
Date(Floor(Date#(DateTermIssued1, 'MMM D YYYY hh:mmTT')),'DD/MM/YY')
Date#(Trim(Left(DateTermIssued1,Index(DateTermIssued1,' ',3)-1)), 'MMM D YYYY')
Date#(Trim(Subfield(DateTermIssued1,':',1)), 'MMM D YYYY hh')

QlikBeginner1
Creator
Creator
Author

Thanks Henric, The first solution worked.

QlikBeginner1_0-1646393001599.png

Date(Floor(Date#(DateTermsIssued, 'MMM DD YYYY hh:mmTT')),'DD/MM/YYY') as DateTermIssued1,
Date(Floor(Date#(DateTermsIssued, 'MMM  D YYYY hh:mmTT')),'DD/MM/YYY') as DateTermIssued2,

Because some of the day values have one and two numbers, ive had to use this IF to bring through the above dates

=IF(ISNULL(DateTermIssued1),DateTermIssued1,DateTermIssued1)

Thanks Again!!!