Team Foundation Server Hosting
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » SQL Server » How to count number of records
       
Author Reply
suresh
posted 14 posts
since Jan 22, 2008 
from

How to count number of records

  Posted on: 22 Feb 2012       
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,



suresh
venkata saibabu
posted  6 posts
since  Feb 22, 2012 
from 

 Re: How to count number of records
  Posted on: 23 Feb 2012        0  
hi friend you can do write the query in below format : declare @act_date date = '2/2/2012' //login date declare @newact_date date set @newact_date = DATEADD(month, 1, @act_date) select COUNT(@newact_date) where @act_date <=GETDATE() .hope it will be helpful
Deepika Srivastava
posted  6 posts
since  Sep 27, 2011 
from  Pune

 Re: How to count number of records
  Posted on: 23 Feb 2012        0  
Hi Suresh,
Try with the Venkata code. it will give you right o/p.
Thanks, If Helps, please mark it as Answer. !!!
       
Nevron Gauge for SharePoint
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved