Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ritumishra01
Contributor III
Contributor III

Date Format (how to pull only year from date)

Hey ,

I have below code 

// Two variables below are to be commented after first load.
//let vStart ='7/1/2023 00:00';
//let vEnd ='6/30/2024 23:59';
//let VFYear = year(vENd);
 
Let vNow = Now();
 
 
If vNow >= vEnd THEN
 
LET vStart = AddYears('$(vStart)', 1);
LET vEnd = AddYears('$(vEnd)', 1);
     
END IF 
LET Vfyear = YearEnd(vEnd);
exit script;
 
 
IN VFYear variable i am trying to store only the year i.e. 23 .
but its giving me null .
 
Labels (2)
8 Replies
Lisa_P
Employee
Employee

let vEnd ='6/30/2024 23:59';
let VFYear = year(Date#(vEnd, 'M/D/YYYY hh:mm'));

ritumishra01
Contributor III
Contributor III
Author

Hey thanks for your reply i only need last two digits in year.

example if year is 2022 then only 22 if 2023 then only 23 .

brunobertels
Master
Master

hi may be this instead 

let vEnd ='6/30/2024 23:59';
let VFYear =right( year(Date#(vEnd, 'M/D/YYYY hh:mm')),2);

ritumishra01
Contributor III
Contributor III
Author

also while i am trying to store it , it is not loading the VFyear could you please help here 

STORE enc4 INTO [lib://CertifiedDataModels/ClinicalDataModelNoPHI/Encounters_fy_$(VFYear).QVD] (qvd);

brunobertels
Master
Master

hi 

this link should hel you 

https://community.qlik.com/t5/QlikView-App-Dev/Store-values-of-variable-in-qvd/td-p/1932462 

 

i don't see whah is exactly "enc4" in your syntax but to store a qvd you need first to have a table 

then you have to first create a table with the result of your variable then you should store it 

ritumishra01
Contributor III
Contributor III
Author

Hey  - actually i am trying to save every year data and hence i am trying to store it based on every year But VFYear varaible is not coming up .

ritumishra01
Contributor III
Contributor III
Author

I am trying to save data based on year. and every year it should get updated so i am trying to use variable and store year in variable.

but while i am trying to store it, VFYear varibale is coming as null 

(only while i store in file)