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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Date conversion

Author  Topic 

parand
Starting Member

8 Posts

Posted - 2008-04-24 : 06:55:48
Hi,

Does anyone know how to convert a datetime stamp to MMMYY format?

As an example suppose a SQL enquiry returns:

Date Value
01/01/2008 10
10/01/2008 15
15/01/2008 25

I want to be able to return:

Date Value
Jan08 50


Many thanks in advance for your help.

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-24 : 07:03:47
forgetting the whole 'formatting' bit for a sec, it seems what you really want is to group by the month...?

something like...

select DATEADD(mm,DATEDIFF(mm,0,[Date]),0),sum(value)
from urTable
group by DATEADD(mm,DATEDIFF(mm,0,[Date]),0)


Em
Go to Top of Page

parand
Starting Member

8 Posts

Posted - 2008-04-24 : 10:51:02
Thanks very much ElanCaster and your suggestion is deeply appreciated.
I have managed to produce the required result by combination of convert and substrings functions availabe.
Go to Top of Page
   

- Advertisement -