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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date comparison problem (from SAP)

Hello,

I extract data related to invoices from SAP (VBRK and VBRP tables). In my transformation application, I include a QVS file with the following code:

//Set start date for extractions

//After February 15th, we only extract 2 years

LET vDateToday= Num(Today());

LET vDateLimit= Num(MakeDate(Year(Today()),'02','15'));

IF $(vDateToday) > $(vDateLimit) then

  LET vStartDate = MakeDate(Year(Today())-2,'01','01');

ELSE

  LET vStartDate = MakeDate(Year(Today())-3,'01','01');

ENDIF

Now, when I create my fact table, I want to only have records where FKDAT >=vStartDate, so my code is like this:

[FactTableSalesReport]:

LOAD

     [InvLine_Sales Document] &'/'& [InvLine_Sales Document Item] AS %OrdLine_Key,

     ...

Resident [InvoiceAll]

Where [Inv_Billing Date]>= $(vStartDate);

But I still get all the records from my InvoiceAll table, and I don't know why. I made that the field [Inv_Billing Date] was a date field, but if I make a test like If([Inv_Billing Date]>=$(vStartDate),1,0), then it always returns one.

1 Solution

Accepted Solutions
luciancotea
Specialist
Specialist

As I remember, SAP uses YYYYMMDD format for the dates:

LET vStartDate = DATE(MakeDate(Year(Today())-2,'01','01'), 'YYYYMMDD');

and don't forget the single quotes:

.

.

... Where [Inv_Billing Date]>= '$(vStartDate)';

View solution in original post

4 Replies
Not applicable
Author

Ah, and I also made sure that some records have a [Inv_Billing Date]<$(vStartDate)...

luciancotea
Specialist
Specialist

As I remember, SAP uses YYYYMMDD format for the dates:

LET vStartDate = DATE(MakeDate(Year(Today())-2,'01','01'), 'YYYYMMDD');

and don't forget the single quotes:

.

.

... Where [Inv_Billing Date]>= '$(vStartDate)';

Peter_Cammaert
Partner - Champion III
Partner - Champion III

And as proof of Lucians statement, in your document go to Settings->Variable Overview and verify the value of vStartDate. It should be in the 40000 ... 50000 range.

Now use the Table Viewer to inspect the [Inv_Billing_Date] field. All values (in the format YYYYMMDD) are larger than vStartDate.

Not applicable
Author

Ah, the problem was that I forgot the single quotes. I should know by now. Thank you for the help.