Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi ,
I am trying to retreive current Year and month using below code in qlikview:
LET vCurrentDate = today();
// Current Year
LET vCurrentYear =Year($(vCurrentDate));
// Current Month
LET vCurrentMonth =($(vCurrentDate));
Always vCurrentYear is populted with 1990 and vCurrentMonth is populated with May.. But I never see correct data has been assigned to these Qlikview variables.
Any thoughts?.
Here are the settings I have :
SET TimeFormat='h:mm:ss TT';
SET DateFormat='YYYY-MM-DD';
SET TimestampFormat='YYYY-MM-DD hh:mm:ss';
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec'
Thanks
Dasu.G
Thanks for the explanation of the low dates Jonathan. I've often wondered about that.
Jonathan
Try:
LET vCurrentDate = today();
LET vCurrentYear = '=Year(vCurrentDate)';
LET vCurrentMonth = '=Month(vCurrentDate)';
Double quotes are a problem, and the dollar expansion doesn't seem to be necessary.
Jonathan
Hi
Your first Let statement sets vCurrentDate to '2013-01-21' (or whatever is the correct value for Today(). The second Let "evaluates" the expression 2013 - 1 - 21 = 1991 and uses 1991 as the day number (which corrreponds to the date 1905/06/13.
You do not need $ expansions here, but if you use them, enclose in single quotes so that instead of evaluating an expression, QV is expanding a string:
LET vCurrentYear =Year('$(vCurrentDate)');
LET vCurrentMonth =Month('$(vCurrentDate)');
But even simpler:
LET vCurrentYear =Year(vCurrentDate);
LET vCurrentMonth =Month(vCurrentDate);
Hope that helps
Jonathan
Thanks for the explanation of the low dates Jonathan. I've often wondered about that.
Jonathan