Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
renjithpl
Specialist
Specialist

Autogenerate a Date field using two variables in input box

Hi All,

I have created two variables vStartDate and vEndDate and in the application i created a input box for both, so the user will enter Start Date and End Date.

I want to create a field called "Date' using the user entered start date and end date.

Eg. vStartDate=02/01/2011
vEndDate = 02/28/2011

so the Date field should be - 02/01/2011, 02/01/2011, . . . . . . . . , 02/28/2011.

Is it possible to have such scenario.?

Ranjit

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

You used lowercase 'mm/dd'. Those should be upper case because 'mm' is for minutes, not months. More generally, I would just set my DateFormat correctly so that I didn't have to individually format every date in the script.

SET DateFormat='MM/DD/YYYY';

If you always want to start with today, don't bother with a variable for it. Just use today() in the script. (Edit: Same if you're using a formula for the end date variable. Just put that formula in the script instead of using a variable.)

[Dates]:
LOAD date(today()+recno()-1) as Date
AUTOGENERATE $(vEndDate)-today()+1;

View solution in original post

6 Replies
Not applicable

Hello Ranjit,

You may try something like Date = vStartDate(GetSelectedValue), vEndDate(GetSelectedValue). Just a try, can u please let me know if that worked?

ANDY

johnw
Champion III
Champion III

You'd need to reload, of course, but this should do it.

[Dates]:
LOAD date($(vStartDate)+recno()-1) as Date
AUTOGENERATE $(vEndDate)-$(vStartDate)+1;

renjithpl
Specialist
Specialist
Author

Hi John,

I have attached a file and i did like you said, but i am getting different dates.

Also, it gives an error message, when i use =today() in my vStartDate. How will i overcome this error and get correct dates.

My vEndDate also i have to type a formula to get my end date, does this autogenerate if i use formula instead of numbers in Variables.?

I am very thankful if you could solve this issue.

Ranjit

renjithpl
Specialist
Specialist
Author

Hi john,

please see my thread. please find the attachment.

Thanks

johnw
Champion III
Champion III

You used lowercase 'mm/dd'. Those should be upper case because 'mm' is for minutes, not months. More generally, I would just set my DateFormat correctly so that I didn't have to individually format every date in the script.

SET DateFormat='MM/DD/YYYY';

If you always want to start with today, don't bother with a variable for it. Just use today() in the script. (Edit: Same if you're using a formula for the end date variable. Just put that formula in the script instead of using a variable.)

[Dates]:
LOAD date(today()+recno()-1) as Date
AUTOGENERATE $(vEndDate)-today()+1;

renjithpl
Specialist
Specialist
Author

Hey John,

From your answer i got lot of ideas how to autogenerate dates through different variables. I got my answer. Thanks a lot. 🙂

Ranjit