Solved

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

Posted on 2011-03-04
4
345 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
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
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 …
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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