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: 
Not applicable

Month() and Year() function with .csv file not working

Hello,

I am selecting data out of  csv file (small file with 8 columns and 1000 rows). 2 of the columns are date (Start_Dt & End_Dt).

I want to get Month and Year out of those dates: Month(Start_Dt) & Year(End_Dt). It does not work. I get no data (just dashes "-").

The Start_Dt and End_Dt dates show up just fine.

However, if I convert that .csv file to excel (.xlsx) and use the same script (except selecting from xcel), Month and Year function works

just fine. But since the source is .csv, we don't want to keep converting to xcel on daily basis.

I have tried using trim, date function on the .csv file but no-go. Any help/pointers are appreciated.

Thanks,

-Sam

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Sam,

Try to use date#() function:

month(date#(Start_Dt, 'format'))

Format must be according to the specific date format in your file, e.g. 'MM DD YYYY', or 'M/D/YY', etc..  I cannot gues, but van see it...

Regards,

Michael

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Sam,

Try to use date#() function:

month(date#(Start_Dt, 'format'))

Format must be according to the specific date format in your file, e.g. 'MM DD YYYY', or 'M/D/YY', etc..  I cannot gues, but van see it...

Regards,

Michael

jagan
Partner - Champion III
Partner - Champion III

Hi

Try the date format when you are loading the data from CSV and check whether the format of the date, if it is not in proper format then then convert date to valid format by using date#() in combination with Alt().  Check the date values that are not giving month and year.

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Michael,

Thanks!! I was using date but did not work... date# did the trick.

Thanks much.

-Sam