February 22, 2012 at 6:25 pm
HI,
I have table student
st_id , st_name, act_date
1 james 2/2/2012
2 albert 2/4/2012
3 johnson 30/1/2012
4 hitler 2/2/2012
you can see the first record the act_date is 2nd Feb 2012.
Addign one month to Every record.
Ex:
Today date is 23rd Feb 2012, see the first record 2nd Feb 2012.
2nd Feb 2012+adding One Month=> 3rd March 2012.
When i logined into my web site (23rd Feb 2012) , it has to show the count Zero.
When i logined into my web site (3rd March 2012), it has to show the count=2 i.e the 1st record and 4th record.
Same process wlll have to follw to other records.
How to write a Query to count that records based on that condition adding after one month to the record.
Thanks,
February 22, 2012 at 7:15 pm
I am bit lost here... is your requirement to find the count of rows that are exactly older than 30 days?
If yes, then use this
DECLARE @Dateparam DATETIME = '3-MAR-2012'
SELECT @Dateparam = DATEADD(D,-30,@Dateparam)
SELECT COUNT(*)
FROM Students
WHERE act_date = @Dateparam
February 23, 2012 at 3:06 am
The answer is possible after:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy