April 29, 2014 at 3:45 am
Hi,
I have a gridview and a dropdown filters in the page. Also I have a date column in gridview which has values like 2014-04-12 and 2014-04-25. Assuming the current budget year if someone adds a row with the year 2016 and when I filter the dropdown I have exclude that 2016 columns using this below query for this current year 2014.
Query:
select ID, Group,CONVERT(Date, Summary_Date) as Summary_Date from Application where Group='" + selectedGroup + "' and Summary_Date <=Dateadd(year,1,getdate()) order by ID, Summary_Date
This shows shows all values of current and new year.
Output:
For this year if I do the filters I should be able to see all values of 2014 and 2015 values upto 2015-01-01. And we move to 2015 year I should be able to see all 2015 values and values upto 2016-01-01 and so on. Pls let me know if you have any questions.
April 29, 2014 at 4:24 am
Hi,
try this..
select ID, Group,CONVERT(Date, Summary_Date) as Summary_Date from Application where Group='" + selectedGroup + "' and Summary_Date <=DATEADD(yy,1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))
order by ID, Summary_Date
April 29, 2014 at 4:40 am
I tried this and what is your suggestion>?
<=DATEADD(yy,DATEDIFF(yy,0,getdate()) + 1,0)
April 29, 2014 at 4:43 am
<=DATEADD(yy,1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))
don't know what is required output .
but above code will give you next year's first date i.e '2015-01-01 00:00:00.000'
April 29, 2014 at 4:45 am
yours worked too and I was asking whether mine is correct.
April 29, 2014 at 4:49 am
yes..your code is correct..
April 29, 2014 at 5:01 am
Okay and Thanks:-)
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply