Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Show data untill end of previous month while loading from SQl

Hi,

i have a sql query

how can add a where statement to hide data of current month?

Thxs

1 Solution

Accepted Solutions
Not applicable
Author

I have used the following anfd it seems to work fine.

Year(#COEDT)*100 + Month(#COEDT) <> Year(curdate())*100 + Month(curdate())

Thxs

View solution in original post

6 Replies
Not applicable
Author

I would add a where clause that exclude records based on a character datestamp truncated down to the month.

SQL:     where convert(char(6), [YourDate], 112) <> convert(char(6), getdate(), 112)

Today the this would return "201204" for April 2012. Any record that is also April 2012 gets excluded.

Not applicable
Author

the logic seems to be fine but it didn't work.

I am getting an error

I'm using:

select ...

....

from

tableA

where

convert(char(6), [(#COEDT)], 112) <> convert(char(6), getdate(), 112

Regards

adhudson
Creator II
Creator II

Hi,

     I double checked iainrutgers's solution. It works fine for me.

     Can you please describe the error you are getting?

     Is the [(#COEDT)] field temporary one?

     As well, I have attached my script for your reference.

Regards

Andrew Hudson

Not applicable
Author

Hi,

Not sure what do you mean by temp date.

I even tried to load the folllowing to see if it may work but it didn't.

convert(char(6), [#COEDT], 112) as dd

I am getting the following error:

Token [ was not valid. Valid tokens: ( + - ? : DAY INF NAN RID ROW RRN CASE CAST CHAR DATE DAYS HASH.

Regards,

Not applicable
Author

I am assuming the convert logic is not working but not sure why1

Not applicable
Author

I have used the following anfd it seems to work fine.

Year(#COEDT)*100 + Month(#COEDT) <> Year(curdate())*100 + Month(curdate())

Thxs