Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
laujerry
Creator
Creator

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
swuehl
MVP
MVP

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

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
Creator
Creator
Author

/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
Specialist III
Specialist III

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