Solved

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

Posted on 2011-03-04
4
336 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:ewangoya
Comment Utility

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
Comment Utility

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
Comment Utility

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

SELECT DATENAME(WEEKDAY,  @CURR_DATE )
0
 
LVL 4

Expert Comment

by:samijsr
Comment Utility
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

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, …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now