Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Setting Begin and End Dates in Script

This should be simple but it is the fist time I have had to do this

If I want to have a beginning and ending reporting month variable set at the beginning of my script what is the proper function/syntax

What I want is :

Begin Month Date = 01/01/2012

End Month Date = 06/30/2012

Not sure of the exact syntax or if LET or SET is the proper way to establish.

Thanks in advance,

Steve

1 Solution

Accepted Solutions
kedar_dandekar
Creator
Creator

Hi Zagzebski,


In that case you can use a string variable, in place of a date variable,

and use it with $() function in your where clause while loading.

Refer attached QVW for details..


The script contains related comments..


HTH,

KD

View solution in original post

12 Replies
jjordaan
Partner - Specialist
Partner - Specialist

Hi Zagzebski,

You can use something like this;

LET vStartMonth = MontStart($(vToday));

LET vEndMonth = MonthEnd($(vToday));

zagzebski
Creator
Creator
Author

Thanks Jereon - Is there a way to hard code the dates I refereence above...Begin Date = 1/1/2012 and End Date= 6/30/2012 in the variable?

jjordaan
Partner - Specialist
Partner - Specialist

Yes you can do it like this:

LET vDate = Date#('2015-12-31');

kedar_dandekar
Creator
Creator

Hi,

Just another way to do so would be using MakeDate function:

LET vBeginMonthDate = MakeDate(2012, 01, 01);

LET vEndMonthDate = MakeDate(2012, 06, 30);

HTH,

KD

zagzebski
Creator
Creator
Author

Thanks KD

To utilize the variable what do I need to do? I tried to use it in a table I was loading but it says field not found?

kedar_dandekar
Creator
Creator

Hi Zagzebski,

Are you planning to use the Begin and End date variables to generate your master calendar data.

or you want to use these variables to filter data from a table while loading?

- KD

zagzebski
Creator
Creator
Author

KD -

I need to use them in a WHERE clause in a couple of the tables I am loading.

kedar_dandekar
Creator
Creator

Hi Zagzebski,


In that case you can use a string variable, in place of a date variable,

and use it with $() function in your where clause while loading.

Refer attached QVW for details..


The script contains related comments..


HTH,

KD

zagzebski
Creator
Creator
Author

Thanks KD - works!

Two quick follow ups:

1. This is part of a transform load so I want these dates to be available when I reload this data into my model. How can I get this so it loads into my variables of my model?

2. Also not 100% sure in the difference between the let variables and the set variables.

Really apprecaite your help on this, thanks again.

Steve