Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
arpita
Contributor III
Contributor III

Covert Date Format from MM/YYYY TO MMM-YYYY

Hi

I created my date field from the file name extension which is in MM/YYYY format but I need it in MMM-YYYY format.

File Name : TTA Reports202011010404288823

FXVOls:
LOAD
Status,
Product,
[Last Amend Date],
[Trading_Entity],
mid(FileName(),46,2)&'/'&mid(FileName(),42,4) as Year _Month

FROM
$(file)
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

The output of Year_Month is 11/2020 but I want it as Nov-2020. 

 

2nd question: Is there a possibility that I can have my QV app reflecting Oct-2020 instead of Nov-2020 from the same file string TTA Reports202011010404288823

2 Replies
dplr-rn
Partner - Master III
Partner - Master III

Change to something like below

 

 

Date(Date#(mid(FileName(),46,2)&'/'&mid(FileName(),42,4),'MM/YYYY'),'MMM-YYYY') as Year _Month

 

 

regarding your second question. use Add months function around the date# expression. 

Date(AddMonths(date#(...),-1),'MMM-YYYY')

arpita
Contributor III
Contributor III
Author

Thanks dilipranjith,

This part did work: Date(Date#(mid(FileName(),46,2)&'/'&mid(FileName(),42,4),'MM/YYYY'),'MMM-YYYY') as Year _Month

 

 

FXVOls:
LOAD
Status,
Product,
[Last Amend Date],
[Trading_Entity],
Date(Date#(mid(FileName(),46,2)&'/'&mid(FileName(),42,4),'MM/YYYY'),'MMM-YYYY') as Year _Month,
Date(AddMonths(date#(Year_Month),-1),'MMM-YYYY')

FROM
$(file)
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

But when I add the 2nd line to the script Date(AddMonths(date#(Year_Month),-1),'MMM-YYYY')....this doesnt work and says cannot find Field Year_Month

Please help