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

Loading past 10 months data

Load *;

SQL Select *

from DM.Da

Where monthstart(CreatedDate,'YYYY-MM-DD')  >= Date(monthstart(dateadd(month,-10,Today(),'YYYY-MM-DD'));

this statement throws an error, monthstart is not avaible in sql server. How can i load data for past 10 months ?

12 Replies
baarathi
Creator III
Creator III
Author

YoussefBelloum
Champion
Champion

Hi,

I'm not very good at the sql syntax, but with Qlik engine you can do this:

Load *

where CreatedDate>= AddMonths(Today(), -6);

SQL Select *

from DM.Da;

make sure to evaluate your CreatedDate field on the load and format it the right way.

baarathi
Creator III
Creator III
Author

sir, But the problem of doing it in Load instead of SQL is it's time consuming.

baarathi
Creator III
Creator III
Author

mto

sunny_talwar

I think some of the functions that you are using here might be Qlik specific functions.... such as Today(), MonthStart... I know Oracle uses SYSDATE for Today() and something like ADD_MONTH for AddMonths and Trunc to get MonthStart... etc... suggest you to talk to your DB guys to give you a way to restrict this to 10 months....

baarathi
Creator III
Creator III
Author

Ya right. I could find equivalent function for Today as GetDate, But for monthstart could not find such match?

sunny_talwar

Which database are you pulling the data from?

baarathi
Creator III
Creator III
Author

SQl server 2014 Management Studio

sunny_talwar