Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
LauraMorris
Contributor III
Contributor III

Dates in Where Clause

I have a loop to generate a table but the WHERE clause involves dates. They come out of the database as DD/MM/YYYY 00:00:00  (Qlik is set to date format of DD/MM/YYYY) The loop is working but if I put the where clause in I get no matches (If I take it out it brings back everything which I do not want). I have used Date(Floor) to try and remove the timestamp but it still remains if I do a straight table of EmployeLoad

 

[EmployeLoad]:
noconcatenate Load
"EMPLOY_REF",
SURNAME,
FORENAME,
MGR_REF,
fullname,
date(floor(STARTDATE)) as STARTDATE,
date(floor("LAST_WORKING_DAY")) as "LAST_WORKING_DAY"

 

For i = Weekend(today()-365) To Weekend(today()) step 7
Let iDate=Date(i);

TimeSheetsRequired:

LOAD Date($(iDate)) As TimeSheetWeekDate,

"EMPLOY_REF" as EmployeeRef

Resident EmployeLoad

Where STARTDATE <= Date($(iDate))
And ("LAST_WORKING_DAY" >= Date($(iDate)) OR isnull("LAST_WORKING_DAY"));
next

1 Reply
Vegar
MVP
MVP

It could be your variable iDate that is causing you trouble. 

Try using dollar expansion of the i. 

Let iDate=Date('$(i)');