Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
zagzebski
Contributor

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

Tags (1)
1 Solution

Accepted Solutions
kedar_dandekar
Contributor

Re: Re: Setting Begin and End Dates in Script

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

12 Replies
jjordaan
Valued Contributor

Re: Setting Begin and End Dates in Script

Hi Zagzebski,

You can use something like this;

LET vStartMonth = MontStart($(vToday));

LET vEndMonth = MonthEnd($(vToday));

zagzebski
Contributor

Re: Setting Begin and End Dates in Script

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
Valued Contributor

Re: Setting Begin and End Dates in Script

Yes you can do it like this:

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

kedar_dandekar
Contributor

Re: Setting Begin and End Dates in Script

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
Contributor

Re: Setting Begin and End Dates in Script

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
Contributor

Re: Setting Begin and End Dates in Script

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
Contributor

Re: Setting Begin and End Dates in Script

KD -

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

kedar_dandekar
Contributor

Re: Re: Setting Begin and End Dates in Script

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
Contributor

Re: Setting Begin and End Dates in Script

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

Community Browser