Crystal Reports & SQL Reporting Services Training Consultants
Account Log in:
Username:
Password:
Excellence can be obtained if you care more than others think is wise, risk more than others think is safe, dream more than others think is practical, expect more than others think is possible
 
Unknown
Institute of IT Trainers - Freelance Trainer of the Year 2006 & 2009
Liverpool Business Connect Member
  Maximum Impact Solutions Limited - Reporting Solutions, Creating Answers
Reporting Solutions - Creating Answers, Crystal Reports, Dashboarding (Xcelsius) & SQL Reporting Services

The Maximum Impact Solutions Blog Feed ME!!!!

13
March

How Do I Calculate the Day Name from a Date Field in SQL?

During a recent SQL training session one of the delegates asked "How Do I calculate the day of the week that an order was placed?"

Solution:

To calculate the name part of any datetime field in SQL, one must use the DateName function:

SELECT  DATENAME(DW, Tablename.Fieldname) AS [Order Day]

FROM Tablename


Note: This returns the full day of the week, i.e. Monday, to return the abbreviated day of the week, amend the SQL syntax to the following:

DATENAME(DW, Tablename.Fieldname, TRUE) AS [Order Day]

If you have any questions, leave us a comment below, or need any assistance, please do not hesitate to Contact Us

MAKE A COMMENT

Name *

Email Address *

Comment *

To prove you are human what is:

88 + 93 =