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

x
?
Solved

ms sql server 2005 - get day from date..(ie..Wednesday)

Posted on 2011-02-25
12
Medium Priority
?
590 Views
Last Modified: 2012-05-11
I have this but I need to convert to see what actual day it is..like wednesday..monday..etc

 DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
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
  • 5
  • 2
  • 2
  • +2
12 Comments
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34981661
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
SELECT DATENAME(dw, @CURR_DATE) AS 'Day'

Open in new window

0
 
LVL 8

Expert Comment

by:rushShah
ID: 34981664
you can do like this,
select DATENAME(WEEKDAY, getdate())

Open in new window

0
 
LVL 5

Expert Comment

by:scgstuff
ID: 34981671
You can use DatePart to get the numeric day of week.  Then you could use that to give you the word for the day of week.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:ncheung
ID: 34981675

Try using DATEPART
http://msdn.microsoft.com/en-us/library/ms174420.aspx

Example:
SELECT DATEPART(dw, GETDATE())
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 34981679
so for examply need to convert to
'Friday' or
'Friday February 15, 2011'

both options would be great...
0
 
LVL 7

Expert Comment

by:ncheung
ID: 34981734
DATENAME will work as illustrated by previous responses.
0
 
LVL 5

Expert Comment

by:scgstuff
ID: 34981745
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
select datename(weekday, @CURR_DATE) + ' ' + convert(varchar, @CURR_DATE) as mydate

Result is: Friday Feb 25 2011 11:49AM

0
 
LVL 8

Expert Comment

by:rushShah
ID: 34981766

DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
SELECT CONVERT(VARCHAR(20), @CURR_DATE, 100)--o/p Feb 25 2011 1:29PM

or

DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
select DATENAME(WEEKDAY, @CURR_DATE)--o/p Friday

Open in new window

0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 2000 total points
ID: 34981770
SELECT DATENAME(WEEKDAY, getdate()) 
+ ' ' + CONVERT(VARCHAR(12), GETDATE(), 100)

Open in new window


Friday Feb 25 2011
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34981784
Applying in your code
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
SELECT DATENAME(WEEKDAY, @CURR_DATE) 
+ ' ' + CONVERT(VARCHAR(12), @CURR_DATE, 100)

Open in new window

0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34981801
SELECT DATENAME(WEEKDAY, getdate()) 
+ ' ' + DATENAME(MM, GETDATE()) + RIGHT(CONVERT(VARCHAR(12), GETDATE(), 107), 9) AS [Month DD, YYYY]

Open in new window


Friday February 25, 2011
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34981806
Modifying your query
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
SELECT DATENAME(WEEKDAY, @CURR_DATE) 
+ ' ' + DATENAME(MM, @CURR_DATE) + RIGHT(CONVERT(VARCHAR(12), @CURR_DATE, 107), 9) AS [Month DD, YYYY]

Open in new window

0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

604 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