SQL PHP HTML ASP JavaScript articles and free scripts to download

Month Function of MSSQL DateTime field

We can get the month part in number 1 to 12 by using Month function in MSSQL. Here is the query to get Month part along with the full date.

select Month(issue_dt) as month, issue_dt from dt

The output of this query is here.
monthissue_dt
12 12/28/2007 7:54:56 PM
10 10/31/2010 7:23:47 PM
10 10/31/2010 7:30:14 PM
10 10/31/2010 7:30:20 PM
2 2/28/2010 7:54:56 PM
As you have seen we have shown month along with the full date, now we will try to list out number of issues in every month by using Group by command. We will display Total number along with the month number. Here is the query.

rs1.open " select COUNT(issue_dt) as no, Month(issue_dt) as isdt from dt GROUP BY Month(issue_dt)

Month isdt
2 1
10 3
12 1
The left column is the month and next column shows number of issues against that month. You can check from the first display list the numbers to the second display list
Google+

Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer