Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi comm,
i want to load data from the last 3 days.
Thats why i want to get today - 3 days to get the date x. And with datex i want to load data into Qlik Sense!
FROM Dashboard.dbo."QLIK_TF_SELL";
WHERE Date(Date#(Date_new,'YYYY.MM.DD')) > Date(Date#('x', 'YYYY.MM.DD'))
and x like i said is today -3d!!!
Can i calc this with var in the script?
thanks for help and advices in advance
-Eric
SQL
can you try below
FROM Dashboard.dbo."QLIK_TF_SELL"
WHERE CONVERT(INT,Date_new) > GETDATE()-3 ;
Sorry for late response,
had something else to do!
First why to int?
and also there is the error "explicit conversion of the date data type to int is not allowed."
Mathematical operation with a date such as addition or subtraction will return an integer value
so getdate() - 3 , will return an int value
We are converting your Date_new value to INT as both comparing values should be in same format.
FROM Dashboard.dbo."QLIK_TF_SELL"
WHERE CONVERT(INT,CONVERT(VARCHAR(10),Date_new)) > GETDATE()-3 ;
OR
FROM Dashboard.dbo."QLIK_TF_SELL"
WHERE CONVERT(INT,CONVERT(VARCHAR(MAX),Date_new)) > GETDATE()-3 ;
thanks for ur great support and now i understand it !
But i have a date coloumn with 2016-09-20
but getting following error:
ErrorMsg: error with converting varchar-value 'Sep 15 2016' into int-data typ.
I dont understand why I have so much problems with converting and restrict data load
Happens with all
FROM Dashboard.dbo."QLIK_TF_SELL"
WHERE CONVERT(INT,CONVERT(VARCHAR(10),Date_new,101)) > GETDATE()-3 ;
I think this is right way but wrong format get error with.
converting problem varchar ' 09/15/2016 ' into in datatyp.
maybew change 101 so format is '2016-09-15' like in my db ?
Where do u get these infos! Pls send link!
must leave now. i ll answer tomorrrow!
BB and thanks
https://www.techonthenet.com/sql_server/functions/index_alpha.php
Hi Eric,
please try this,
FROM Dashboard.dbo."QLIK_TF_SELL"
WHERE Cast(CONVERT(VARCHAR(10),Date_new,112) as int) > Cast (Convert(varchar(10),GETDATE()-3,112) as int) ;
This convert will change the date into '20160928' this format
Thanks for ur time spend in this problem.(u will get a lot of likes) Thanks for this solution works very well!!!
Love this Community!!