Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

getting stuck in SQL WHERE = Today when date is YYYYMMDD

Hey,

I'm trying to retrieve data, limiting it in SQL according to Today’s date.

The problem is that the date is stored in YYYYMMDD format, therefore not in proper SQL format

Things like

WHERE Date = GetDate()

Or


DATEADD(day, 0, CURRENT_TIMESTAMP); 

Or


WHERE Date = CONVERT(CHAR(10),GETDATE(),112);

WHERE Date = CONVERT(VARCHAR(8), GETDATE(), 112) AS [YYYYMMDD]

If (to avoid confusion) we now define the field I need to look in for today’s date as MyField, how would the script look like?

Load *;

SQL SELECT

Field1, Field2, MyField from Server.table WHERE MyField = (?);

Thank you!

12 Replies
sudeep_d
Partner - Creator
Partner - Creator

date# equivalent function in sql wud solve my query..i guess

thanks

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Yep - and there is the QV equivalent. Have you looked in the F1 help?

LET vToday = Date(Today(),'DD-MMM-YY');

LOAD.....

WHERE Date(Date#(MyField,'DD-MMM-YY'),'DD-MMM-YY') = '$(vToday)';

sudeep_d
Partner - Creator
Partner - Creator

hi jason,

i am fetching data from SAP which uses SQl selectstatement before load hence i need sql function to change the data in date format.

eg:

a100:

load

myfield,

z_z4;

sql select myfield z_z4 from table1;

script looks something like this .. so what should be my where statement after table1??

date# wont work because it's not a sql function

thanks for concern

sudeep