Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mahesh.sanka
Starting Member
18 Posts |
Posted - 2012-09-03 : 02:27:42
|
| Hi All,I have one table which contains Datetime filed.CALLDATE2012-05-022012-04-022012-03-022012-03-05Now i have to build a query in such a way that the o/p should be in the following formatMarch-2012 2April-2012 1May-2012 1Please guide me in this query building Thanks in AdvanceThanks & Regards,Mahesh Kumar Sanka |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-09-03 : 04:30:17
|
[code]select datename(month, CALLDATE) + '-' + datename(year, CALLDATE), count(*)from yourtablegroup by datename(year, CALLDATE), datename(month, CALLDATE)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mahesh.sanka
Starting Member
18 Posts |
Posted - 2012-09-03 : 04:54:36
|
| Thanks very much for your help. My Problem has been solved.Thanks & Regards,Mahesh Kumar Sanka |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-03 : 15:19:24
|
| i would suggest doing this at front end if possible especially if you've plans of doing some date manipulations like sorting,comparison etc with this returned resultset else it makes manipulations difficult due to conversion of data type to varchar just for formatting functions.I'm more comfortable in bring them as date values itself and then doing the formatting at front end using date functions------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|