Skip to content
Fix Code Error

Get day of week in SQL Server 2005/2008

March 13, 2021 by Code Error
Posted By: aaaa

If I have a date 01/01/2009, I want to find out what day it was e.g. Monday, Tuesday, etc…

Is there a built-in function for this in SQL Server 2005/2008? Or do I need to use an auxiliary table?

Solution

Use DATENAME or DATEPART:

SELECT DATENAME(dw,GETDATE()) -- Friday
SELECT DATEPART(dw,GETDATE()) -- 6
Answered By: Anonymous

Related Articles

  • Apache server keeps crashing, "caught SIGTERM, shutting…
  • Javascript and css animation
  • Get week day name from a given month, day and year…
  • Get a list of dates between two dates
  • Get the correct week number of a given date
  • How to generate list objects within tidytable mutate…
  • How to get min max day in a week every month?
  • How to add a unique id to an array in one loop instead of…
  • Obtain most recent value for based on index in a pandas…
  • Get first day of week in SQL Server

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Convert list to tuple in Python

Next Post:

How to convert an array to object in PHP?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error