Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
i have a sql query
how can add a where statement to hide data of current month?
Thxs
I have used the following anfd it seems to work fine.
Year(#COEDT)*100 + Month(#COEDT) <> Year(curdate())*100 + Month(curdate())
Thxs
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.
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
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
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,
I am assuming the convert logic is not working but not sure why1
I have used the following anfd it seems to work fine.
Year(#COEDT)*100 + Month(#COEDT) <> Year(curdate())*100 + Month(curdate())
Thxs