Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-04
4
Medium Priority
?
349 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

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…
In this article I will describe the Backup & Restore 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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 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