?
Solved

week  date in 'Friday' format for ms sql server 2005

Posted on 2011-03-04
4
Medium Priority
?
347 Views
Last Modified: 2012-05-11
How do I conver this:
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())

to this:
'Friday'
0
Comment
Question by:GlobaLevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35038788

DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())

SELECT
  CASE (DATEPART(dw, @CURR_DATE) + @@DATEFIRST) % 7
    WHEN 1 THEN 'Sunday'
    WHEN 2 THEN 'Monday'
    WHEN 3 THEN 'Tuesday'
    WHEN 4 THEN 'Wednesday'
    WHEN 5 THEN 'Thursday'
    WHEN 6 THEN 'Friday'
    WHEN 0 THEN 'Saturday'
  END
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 35038850

DECLARE @CURR_DATE smalldatetime
  SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
DATENAME(WEEKDAY,  @CURR_DATE )
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 2000 total points
ID: 35038852

DECLARE @CURR_DATE smalldatetime
  SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())

SELECT DATENAME(WEEKDAY,  @CURR_DATE )
0
 
LVL 4

Expert Comment

by:samijsr
ID: 35043169
You can not store/assign a Text data in datetime data Type.

However you can use function to display Day Name  in Select statement

SELECT DATENAME(WEEKDAY,  @CURR_DATE )
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

741 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