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)
 DateTime

Author  Topic 

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-11-17 : 12:41:15
Trying to use datename to give me both month and year, example

11-18-2004 is current data

I want it to show November 2004.

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-11-17 : 12:50:17
This might work I guess:
select datename(month,dbo.juliandate(JULDATE)),datename(year,dbo.juliandate(JULDATE)) from MAUDIT
???
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-11-17 : 13:23:43
what's wrong with this:

declare @date datetime
set @date = '20041118'
select datename(m, @date) + ' ' + convert(char(4), year(@date))




Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-11-17 : 14:07:31
Getting closer, except that 20011118 is really just one instance, I want the logic to apply to 2000 rows of data. Somewhat new to sql, sorry if this is an easy to solve
Go to Top of Page

samssb
Starting Member

10 Posts

Posted - 2006-11-17 : 14:15:56
select datename(m, yourdatecolumn) + ' ' + convert(char(4), year(yourdatecolumn))
from yourtable
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-11-17 : 14:21:56
I should of included more information in original post, I am getting the date from the following function first:
convert(char,dbo.juliandate(JULDATE),110), is it as easy as plugging that in as the column name cause it doesnt seem to be working:

select datename(m,(convert(char,dbo.juliandate(JULDATE),110)) from MAUDIT
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-11-17 : 15:09:32
I believe I found my issue, I was missing a )
Go to Top of Page
   

- Advertisement -