Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Reading date format from a file name

Hi All,

I have a file with filename as abc_201501.xls.

I have to separate the date part from the filename and check whether it has the format of YYYYMM. I have managed to separate just the date part from the file name using the subfield function. I am now having 201501 stored in a field. How do I now check whether this format matches with the date format YYYYMM.

Thanks,

Asma

3 Replies
Ralf-Narfeldt
Employee
Employee

IsNum(Date#(InputField, 'YYYYMM'))

where InputField is the field containing 201501 for example

It will return true if it's a valid date

anbu1984
Master III
Master III

Try this expr. If it is valid YYYYMM then it returns -1 else 0

IsNum(Date#('201501','YYYYMM'))

peter_turner
Partner - Specialist
Partner - Specialist

Hi Asma,

You would need to get QV to try and recognise that as a date using the date#(MyDate,'YYYYMM') function, where the MyDate is your date from the file.

If QV is able to recognise that as a valid date it will also have a numeric equivalent such as 42005 which you can test against. the test would fail if the format was wrong or return a null.