Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
madhubabum
Creator
Creator

How to get year dynamically?

Hi Experts

I am having the following issue,Here i am having the following variables

LET vStartYear=2013;

LET vCurrentYear=year(today());

LET vMinDate=01-01($(vCurrentYear) - $(vStartYear));

OutPut: -3

But, How we can get 01-01-2013 dynamically

Thanks

Madhu

8 Replies
Chanty4u
MVP
MVP

jonathandienst
Partner - Champion III
Partner - Champion III

Use:

Let vMinDate = MakeDate(vStartYear, Month(Today()), Day(Today()));

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
tresesco
MVP
MVP

may be like:

Let vMinDate=YearStart(Today(), -3) ;

Not applicable

=date#(YearStart(Today(), -3) ,'dd-mm-yyyy')

madhubabum
Creator
Creator
Author

Hi Jonathan dienst,

Thank you very much for your reply.

Here i am getting output like :  1/7/2013 (as mentioned above code)

But, I want as following format   01-01-2013.


How , we can achieve. 

Chanty4u
MVP
MVP

date(ur datefield,' mm-dd-yyyy') as year

tamilarasu
Champion
Champion

Try,

Let vMinDate= Date(YearStart(Today(), -3) ,'DD-MM-YYYY')

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Storing a date as a number or as a text value in a variable (variables, because of being an MS VBScript object,  cannot store dual values) both have advantages in specific cases.

If

  • you want to use vMinDate in calculations or to control script executing, store it as a number. Calculations will be done on numerical values anyway
  • you want to use vMinDate to display a loaded/calculated date in a text on a sheet, store it as a string.

When using a date in a variable in a situation where the format does not correspond to the required format, conversions must be done. You can avoid these by choosing the best storage type in advance.

In the end, it doesn't really matter much for QlikView because you can always convert from one format to the other. But it means more work for both you and the QV engine(s).

Best,

Peter