Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
how to achieve date format as
let vcurrentyear = year(Today());
let vr = '07/01/(vcurrentyear)' ;
where we want to make vcurrentyear dynamic .
Hi @ritumishra01 ,
The concept of the code is that you need an initial declaration of the entity storing the dates, and then a mechanism to update the dates yearly. If you already have initial declaration, then yes you can load the old file and then store the changed data into a new file.
In summary,
vYear = Year(Today());
vYY = Right('$(vYear)', 2);
STORE enc4 INTO [lib://authenticateddata\wbhi_$(vYear)\Enc_fy_$(vYY).qvd](qvd);
If I understand your question correctly, then by using makedate() function.
Let vr = makedate($(vcurrentyear), 07, 01);
Did it work for you @ritumishra01 ?
I am trying to compare two dates
if(date($(vcurrentdate)) >= date($(vStartCheck))) then
let vStart1 = date#('07/01/$(vcurrentyear)','MM/DD/YYYY') else
here else statement is not working
Hi,
Code below works fine with me. But this is the control statements IF (Outside the LOAD). Qlik Help
let vStartCheck = '6/1/2023';
let vcurrentyear = year(Today());
let vcurrentdate = '07/01/$(vcurrentyear)'; //MakeDate($(vcurrentyear), 07, 01)
Trace vcurrentyear: $(vcurrentyear);
Trace vcurrentdate: $(vcurrentdate);
If date($(vcurrentdate)) >= date($(vStartCheck)) THEN
let vStart1 = date#('07/01/$(vcurrentyear)','MM/DD/YYYY');
ELSE
let vStart1 = 'Tomato';
END IF
Trace vStart1: $(vStart1);
Now if you want the if statement to be inside the LOAD (Qlik Help), this is the syntax:
If(A = B, <Do if True>, <Do if False>)
Hey Hesham, thanks for your response.
i am using the below query .and i could not achieve what is needed.
IF-ELSE is not working as expected.
what we are looking for is this that vstart should be '7/1/2023 00:00' and vENd should be '6/30/2024 23:5923:59';
and as soon as '6/30/2024 23:5923:59'; date reaches .Vstart should become 7/1/2024 00:00' and Vend should be '6/30/2025 23:5923:59';.
Any help will be much apriciated .
let vcurrentyear = year(Today());
let vcurrentyear_1 = (year(today())+1);
let vcurrentyear_2 = (year(today())+2);
let vcurrentdate = date(today(),'MM/DD/YYYY');
let vStartC = num(date#(MakeDate($(vcurrentyear), 07,01),'MM/DD/YYYY'));
let vEndC =num(date(MakeDate($(vcurrentyear_1),06, 30),'MM/DD/YYYY'));
IF(NUM($(vcurrentdate)) > NUM($(vStartC)))
THEN
let vStart = date#('07/01/$(vcurrentyear)','MM/DD/YYYY') ;
let vEnd = date#('06/30/$(vcurrentyear_1)','MM/DD/YYYY');
ELSE
let vStart = date#('07/01/$(vcurrentyear_1)','MM/DD/YYYY');
let vEnd = date#('06/30/$(vcurrentyear_2)','MM/DD/YYYY');
END IF
;
Hi @ritumishra01 ,
Your scenario is a bit tricky, as it needs initial declaration, and then continue with the logic.
Code below sets the variable of their initial value and then checks the condition. After running the script for the first time, the variables are defined and saved in the app. Then, you have to comment the first two lines so the variables are not overwritten with the initial values again.
// Two variables below are to be commented after first load.
Let vstart = '2020-07-01 00:00:00.000';
Let vENd = '2021-06-30 00:00:00.000';
// Let vNow = Now();
Let vNow = '2021-08-05 14:57:24.000'; //Defining my own Now just to test code
If vNow >= vENd THEN
LET vstart = AddYears('$(vstart)', 1);
LET vENd = AddYears('$(vENd)', 1);
END IF
Trace vstart: $(vstart);
Trace vENd: $(vENd);
Check it and let me know if it works.
how will this set vStart and Vend every year ?dynamic loading ?
Did you try to run the code and change the vNow value? If you do so you will see that vStart and Vend are changing dynamically.
When you want to deploy the app, make variable vNow = Now() and schedule the task in QMC as per your preference.