Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

laujerry
Contributor

Load Script - Date Issue

Hi all, please advise what's wrong with the following script, thanks!

LET vYesterday=MakeDate(2013,10,12);

[VBAK]:

LOAD

   VBELN,KUNNR,BSTNK,

   VKGRP,VKORG,VTWEG,

   SPART,AUDAT,VDATU,

   AUART,WAERK,KNUMV,

   FAKSK,ERNAM,VKBUR,

   KTEXT,ERDAT,ERZET;

SQL Select

   VBELN KUNNR BSTNK

   VKGRP VKORG VTWEG

   SPART AUDAT VDATU

   AUART WAERK KNUMV

   FAKSK ERNAM VKBUR

   KTEXT ERDAT ERZET

from VBAK WHERE

   Date(ERDAT,'dd/MM/yyyy')='$(vYesterday)';

/QTQVC/OPEN_STREAM failed after 00:00:00 Key = SQL_ERROR (ID:00 Type:E Number:001 Comma without preceding colon (after OPEN ?).)

4 Replies
MVP
MVP

Re: Load Script - Date Issue

The SQL WHERE clause is sent to the DB driver as is (after doing the dollar sign expansion only), and your driver probably doesn't know the QV Date() function.

Either use a function that is supported by the driver, or compare the field directly with a properly formatted variable.

Not applicable

Re: Load Script - Date Issue

Hello,

Do it like this :

let vYesterday = date(Today()-1,'YYYYMMDD'); // Dates in SAP are like this

trace >> $(vYesterday); //

...

from VBAK WHERE

   ERDAT ='$(vYesterday)';

laujerry
Contributor

Re: Load Script - Date Issue

/QTQVC/OPEN_STREAM failed after 00:00:00 Key = SQL_ERROR (ID:00 Type:E Number:001 "'20131015'" is not a valid comparison operator.)

It still reports error

sudeepkm
Valued Contributor III

Re: Load Script - Date Issue

you may also have to use date variable in your script like below:

$(#vYesterday) or '$(#vYesterday)'

A good article on Date fields by Henric at here: QlikView Date fields

Community Browser