Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
smilingjohn
Specialist
Specialist

date

Hi All,

PLease  correct me if i am wrong .

I am trying to create a variable which shouwl hold the value 01/01/2015 for which i am describing in the script as metion below

vReportYearStart = =Date(YearStart(AddYears(01/01/2015,'MM/DD/YYYY'))))

Thanks in advace

7 Replies
karthikoffi27se
Creator III
Creator III

Hi

You can use just this

Let vReportYearStart = =Date(01/01/2015,'MM/DD/YYYY')


Many Thanks

Karthik

Gysbert_Wassenaar

ÁddYears( 01/01/2015, 'MM/DD/YYYY')

AddYears needs an integer as second parameter, not a date format string. And it needs a data value as the first parameter. In this case you're giving it 1 divided by 1 divided by 2015, which is a very small number that corresponds to December 30th 1899.

If you want vReportYearStart to have the date value of the first of january of 2015 then use:

LET vReportYearStart = Date(MakeDate(2015),'DD/MM/YYYY');


talk is cheap, supply exceeds demand
smilingjohn
Specialist
Specialist
Author

Thanks karthi

After creating the variable of 01/01/2015

but after your suggestion of creating the

vReportYearStart = Date(01/01/2015,'dd/MM/yyyy')

I am getting 01/01/2015

and after that iam creating the below variable  to get 2015/12/01 this date

ReportYearAccumalate = MonthStart(AddMonths(Date#('$(vReportYearStart)'),-1));

but i am getting  12-01-2014


please help what needs to be changed

smilingjohn
Specialist
Specialist
Author

Hi Gysbert

You are correct

After creating the variable

Let vReportYearStart = Date(MakeDate(2015),'DD/MM/YYYY');

Now i get 01/01/2015 

and i am creating the belwo variable to get 2015/12/01

Let vReportYearAccumalate = MonthStart(AddMonths(Date#('$(vReportYearStart)'),-1)

but after debugging i see nothing in the vReportYearAccumulate as shown in the below  screenshot

Gysbert_Wassenaar

That could be because there's a parenthesis missing at then end. And if you're using Monthstart then you don't need Addmonths as well. Monthstart also accepts an offset parameter:

LET vReportYearAccumalate = Date(MonthStart( $(vReportYearStart), -1),'DD/MM/YYYY');


talk is cheap, supply exceeds demand
smilingjohn
Specialist
Specialist
Author

hi  Gysbert

now it shos 1984

LET vReportYearAccumalate = Date(MonthStart( $(vReportYearStart), -1),'DD/MM/YYYY');

otput is is attached in a screenshot

Gysbert_Wassenaar

LET vReportYearStart = Date(MakeDate(2015),'DD/MM/YYYY');

LET vReportYearAccumalate = Date(MonthStart(MakeDate(2015), -1),'DD/MM/YYYY');


talk is cheap, supply exceeds demand