

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SQL WHERE Date >Today()
Hello!
I have SQL table and column Date.
Is it possible to make WHERE limited selection in order to get only records with Data for last tree month..... like
InMonth(Date,Today(),-3)
- Tags:
- new_to_qlikview
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are doing the comparison on the SQL Where clause, you can use the SQL syntax supported by your server - for example, in SQL Server
SQL SELECT *
From dbo.MyData
Where Date >= DateAdd(m, -3, GetDate());
MySQL, Oracle etc will have different syntax - but this avoids date formatting issues.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create a Variable as below
Let vTodayMinus3Month = AddMonths(Today(),-3);
Now load as per
TableName:
Load * From TableName Where Date >= '$(vTodayMinus3Month)';

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
create a variable for that 3mnths and use it in load stmnt..


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are doing the comparison on the SQL Where clause, you can use the SQL syntax supported by your server - for example, in SQL Server
SQL SELECT *
From dbo.MyData
Where Date >= DateAdd(m, -3, GetDate());
MySQL, Oracle etc will have different syntax - but this avoids date formatting issues.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ruslans,
You can do these using variables,
LET vStartDate= Monthstart(Addmonths(Today(),-3))
so by these variable it will consider like for today it will take then it will return , 01/10/2015
after that you can use that variable inside SQL statement by,
Last3MDATA:
LAOD *;
SQL SELECT *
From dbo.MyData
Where Date >= $(vStartdate);
Note:Please check the date format in every area(DD/MM/YYYY or YYYY-MM-DD)
Regards,
Koushik


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, that is exactly what I wanted.
