Solved

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

Posted on 2011-03-04
4
346 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 500 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

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

728 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