Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
soniasweety
Master
Master

Load only from perticular month

hi all

i have data from jan 2018 in my data base    but I wan to load only from may 1st -2018

My date

createdDate = 4/30/2018  7:39:24 PM

how to load  only from may?  what is the where condition?

Thanks

Sony

1 Solution

Accepted Solutions
Colin-Albert

This should work by setting the date as a variable CDate formatted as YYYY-MM-DD and using that date in the where clause.

Let CDate = date(monthstart(addmonths(today(), -3)), 'YYYY-MM-DD') ;

LOAD

     ID,

     CreatedDate;

sql select

     ID,

     CreatedDate

where createdDate >= '$(CDate)'

;

View solution in original post

15 Replies
sudhirpkuwar
Partner - Creator II
Partner - Creator II

SQL Select * from

where createdDate>=5/1/2018

jaumecf23
Creator III
Creator III

Hi.

try something like this :

where num(Month(Date#(createdDate, 'MM/DD/YYYY HH:mm:ss TT')))=5

soniasweety
Master
Master
Author

but I need dynamic

and Database where condition I need   because  am writing this condition in qvd generator.

dapostolopoylos
Creator III
Creator III

If you want to filter your data in LOAD script then:

LOAD

.....

Where

     Num(Month(createdDate))=5

If you want to filter your data in the db level add this to the where clause of your SQL query:

SELECT

     *

FROM

     Table

WHERE

     MONTH(createdDate)=5

Father/Husband/BI Developer
sudhirpkuwar
Partner - Creator II
Partner - Creator II

can you be more specific

Dynamic means what...?

soniasweety
Master
Master
Author

it is not dynamic  right?

for example I have 2 yrs data I wil get  both years data  greater than april.   but I need data greater than  April 2018 only

how to do in Sql server Db

wilsonwebb
Partner - Contributor III
Partner - Contributor III

Load

*   ;

SQL Select

*

FROM TableName

Where createdDate > '4/30/2018' ;

Colin-Albert

Using this expression in the where clause of the sql part of the QlikView load script, will dynamically load data from the 1st of the month 3 months ago.  The date(floor()) function converts the datetime value monthstart() to a date.

    where createdDate >= date(floor(monthstart(addmonths(today(), -3))))


So    
if today is 2018-06-16  Then the load will use   where createdDate >= 2018-03-01

         if today is 2018-06-17  Then the load will use   where createdDate >= 2018-03-01

         if today is 2018-07-02  Then the load will use   where createdDate >= 2018-04-01


You can change the -3 to whatever value you prefer.

soniasweety
Master
Master
Author

its not working giving

today is not sql server function