Solved

How to show months from a sql view

Posted on 2008-09-29
7
201 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL 2005 Srink database in chunks 4 58
Pivot Query Problem 9 41
Passing value to a stored procedure 8 99
SQL query to summarize items per month 5 59
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

772 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