Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
How to write condition at SQL Query to extract only Previous Quarter data (Dynamically) from SQL Server to QlikView.
Date filed format '201911'
Thanks, Nihhal.
Try if it helps....!!
SELECT * FROM
table_name
WHERE
TO_DATE( your_date_field, 'YYYYMM' )
BETWEEN trunc(add_months(SYSDATE,-3),'Q') AND trunc(add_months(SYSDATE,0),'Q') - ( 1 / ( 24 * 60 * 60 ) )
(Oracle SQl Syntax, change function syntax if you are on MS SQL Server)
Thanks for response, can you share SQL Server syntax if you have idea actually i am new to it.
SQL Server...!
SELECT * FROM
"table_name"
WHERE
CONVERT(DATETIME, "your_date_field", 'YYYYMM' )
BETWEEN trunc(dateadd(month, -3, GETDATE()),'Q') AND trunc(dateadd(month, 0, GETDATE()),'Q') - ( 1 / ( 24 * 60 * 60 ) )
Nihhal, did the last post get you what you needed? If so, do not forget to come back to the thread and use the Accept as Solution button on the post to mark it and give credit to the poster as well as let the other Community Members know that it did work.
Here is something else though that you may want to consider:
https://community.qlik.com/t5/Qlik-Design-Blog/Preceding-Load/ba-p/1469534
That might be another way to do things.
Regards,
Brett