Solved

How to show months from a sql view

Posted on 2008-09-29
7
194 Views
Last Modified: 2010-04-21
I have a view that shows invoicing data from the past through today's date.  I used a datepart function to seperate the month out from the date of the invoice, however, it comes out as 1 through 12.  Is there a way to get the month to show up as either March or Mar vs. 3?
Thanks,
JoMar
0
Comment
Question by:JoMar
7 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 300 total points
ID: 22600610
select datename(m, datefield)
from yourtable
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 150 total points
ID: 22600611
check out DATENAME(month, yourdatefield) instead.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22600633
angelIII, are you suggesting that m in the datepart function doesn't work?  By the time difference of our responses I doubt that you are, just making sure.  :)
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 6

Assisted Solution

by:RemcovC
RemcovC earned 50 total points
ID: 22600659
@chapmandew

The syntax is: DATENAME ( datepart , date )
and the datepart for a month can either be m, mm, month

see: http://msdn.microsoft.com/en-us/library/ms174395.aspx
0
 

Author Closing Comment

by:JoMar
ID: 31501366
Thanks to all - I awarded the most points to chapmandew since his came in first and was correct.  I also awarded some to angellll since he had the same thing and was also correct.  And I awarded som to RemcovC for the syntax information.  Great job to all and thanks.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22600744
>angelIII, are you suggesting that m in the datepart function doesn't work?  
as you assumed, I was responding to the questioner, and had not seen your post until I posted...
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22601826
RemcovC, Yes, I'm aware.  Thank you.  :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now