Month Function of MSSQL DateTime fieldWe 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.
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.
| 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 |
rs1.open " select COUNT(issue_dt) as no, Month(issue_dt) as isdt from dt GROUP BY Month(issue_dt)
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