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

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
capriconuser
Creator
Creator

Extract Month and Year from file name separately

hi 

I have a file name like this 

Abc-June-2021.xlsx

Now i am trying to extract Month and year like this in script 

 

 Trim(Replace(FileBaseName(),'MMailBoxUsage-','')) as MailBox_Date

 

and the output is June-2021 .. but now i want to extract Month and Year separately from MailBox_Date field .. 

how i do this ?

 

Labels (3)
1 Reply
Taoufiq_Zarra
MVP
MVP

@capriconuser 

if you have :

Set LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';

you can use Month(Date#(MailBox_Date,'MMMM-YYYY') for the month and ,Year(Date#(MailBox_Date,'MMMM-YYYY')) for the year

for example :

Input:

LOAD *,Year(Date#(MailBox_Date,'MMMM-YYYY')) as Year_MailBox_Date,Month(Date#(MailBox_Date,'MMMM-YYYY')) as Month_MailBox_Date INLINE [
MailBox_Date
June-2021
];

the output:

Taoufiq_Zarra_0-1628151282459.png

 

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉