Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
veldetta
Contributor III
Contributor III

error with if statement in load script

I have some code which is failing on my testing server but runs fine locally.  The code is as follows:

 

 

HolidayList:
LOAD
	Concat(chr(39)&date([HLDY_DT])&chr(39),',') as HolidayDates
Resident tempHolidays
where Year([HLDY_DT]) >= '2019';

Let vPublicHolidays = fieldvalue('HolidayDates',1);

drop table tempHolidays;

if LastWorkDate(MonthStart(Max(Today(1))), 1, $(vPublicHolidays)) = Today(1) then;
	Set vHoliDate = 'True';
ELSE;
	Set vHoliDate = 'False';
end if;

if (vHoliDate = 'True') or (vBypass1stWorkDayofMonth = 1) Then;

         [run some code]

end if;

 

 

However, when i run the script on the testing server, this is the error:

 

6/21/2019 12:14:02 AM: 0046  HolidayList:
6/21/2019 12:14:02 AM: 0047  LOAD
6/21/2019 12:14:02 AM: 0048  	Concat(chr(39)&date([HLDY_DT])&chr(39),',') as HolidayDates
6/21/2019 12:14:02 AM: 0049  Resident tempHolidays
6/21/2019 12:14:02 AM: 0050  where Year([HLDY_DT]) >= '2019'
6/21/2019 12:14:02 AM:       	1 fields found: HolidayDates, 1 lines fetched
6/21/2019 12:14:02 AM: 0052  Let vPublicHolidays = fieldvalue('HolidayDates',1)
6/21/2019 12:14:02 AM: 0054  drop table tempHolidays
6/21/2019 12:14:02 AM: 0056  if LastWorkDate(MonthStart(Max(Today(1))), 1, '1/1/2019','1/12/2019','1/13/2019','1/19/2019','1/20/2019','1/21/2019','1/26/2019','1/27/2019','1/5/2019','1/6/2019','10/12/2019','10/13/2019','10/14/2019','10/19/2019','10/20/2019','10/26/2019','10/27/2019','10/5/2019','10/6/2019','11/10/2019','11/11/2019','11/16/2019','11/17/2019','11/2/2019','11/23/2019','11/24/2019','11/28/2019','11/3/2019','11/30/2019','11/9/2019','12/1/2019','12/14/2019','12/15/2019','12/21/2019','12/22/2019','12/25/2019','12/28/2019','12/29/2019','12/7/2019','12/8/2019','2/10/2019','2/16/2019','2/17/2019','2/18/2019','2/2/2019','2/23/2019','2/24/2019','2/3/2019','2/9/2019','3/10/2019','3/16/2019','3/17/2019','3/2/2019','3/23/2019','3/24/2019','3/3/2019','3/30/2019','3/31/2019','3/9/2019','4/13/2019','4/14/2019','4/20/2019','4/21/2019','4/27/2019','4/28/2019','4/6/2019','4/7/2019','5/11/2019','5/12/2019','5/18/2019','5/19/2019','5/25/2019','5/26/2019','5/27/2019','5/4/2019','5/5/2019','6/1/2019','6/15/2019','6/16/2019','6/2/2019','6/22/2019','6/23/2019','6/29/2019','6/30/2019','6/8/2019','6/9/2019','7/13/2019','7/14/2019','7/20/2019','7/21/2019','7/27/2019','7/28/2019','7/4/2019','7/6/2019','7/7/2019','8/10/2019','8/11/2019','8/17/2019','8/18/2019','8/24/2019','8/25/2019','8/3/2019','8/31/2019','8/4/2019','9/1/2019','9/14/2019','9/15/2019','9/2/2019','9/21/2019','9/22/2019','9/28/2019','9/29/2019','9/7/2019','9/8/2019') = Today(1) then
6/21/2019 12:14:02 AM:       Error: Script line error: 
6/21/2019 12:14:02 AM:       General Script Error
6/21/2019 12:14:02 AM:       Execution Failed
6/21/2019 12:14:02 AM:      Execution finished.

 

 

Looks like it's failing after the first 'If statement'.  Can someone have a look and tell me what might be the issue?  Thanks!

BTW.. i've tried with and without the semicolons on the If statements.... still no dice.

Labels (1)
1 Solution

Accepted Solutions
veldetta
Contributor III
Contributor III
Author

Thanks for asking the question.  I'm using v12.0... Server must have a lower version. 

I changed the code... this works:

 

HolidayList:
LOAD
	Concat(chr(39)&date([HLDY_DT])&chr(39),',') as HolidayDates
Resident tempHolidays
where Year([HLDY_DT]) >= '2019';

Let vPublicHolidays = fieldvalue('HolidayDates',1);

drop table tempHolidays;

set vGetHoliday = LastWorkDate(MonthStart(Max(Today(1))), 1, $(vPublicHolidays));

if vGetHoliday = Today(1) then
	Set vHoliDate = 'True';
ELSE
	Set vHoliDate = 'False';
end if;

if (vHoliDate = 'True') or (vBypass1stWorkDayofMonth = 1) Then

       [run some code]
end if;

View solution in original post

3 Replies
PrashantSangle

Are you sure exact code runs on local machine??
As per if.. then.. else... syntax there is no ; after then.
https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptControlS...

do you have same version on both?

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
sasikanth
Master
Master

HolidayList:
LOAD
	Concat(chr(39)&date([HLDY_DT])&chr(39),',') as HolidayDates
Resident tempHolidays
where Year([HLDY_DT]) >= '2019';

Let vPublicHolidays = fieldvalue('HolidayDates',1);

drop table tempHolidays;

if LastWorkDate(MonthStart(Max(Today(1))), 1, $(vPublicHolidays)) = Today(1) then
	Set vHoliDate = 'True';
ELSE
	Set vHoliDate = 'False';
end if;

if (vHoliDate = 'True') or (vBypass1stWorkDayofMonth = 1) Then

      [run some code]

end if;

try above code,

veldetta
Contributor III
Contributor III
Author

Thanks for asking the question.  I'm using v12.0... Server must have a lower version. 

I changed the code... this works:

 

HolidayList:
LOAD
	Concat(chr(39)&date([HLDY_DT])&chr(39),',') as HolidayDates
Resident tempHolidays
where Year([HLDY_DT]) >= '2019';

Let vPublicHolidays = fieldvalue('HolidayDates',1);

drop table tempHolidays;

set vGetHoliday = LastWorkDate(MonthStart(Max(Today(1))), 1, $(vPublicHolidays));

if vGetHoliday = Today(1) then
	Set vHoliDate = 'True';
ELSE
	Set vHoliDate = 'False';
end if;

if (vHoliDate = 'True') or (vBypass1stWorkDayofMonth = 1) Then

       [run some code]
end if;