Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
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

@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") 😉