stored procedure datetime question.

TomPhillips

Active member
Joined
Feb 24, 2005
Messages
33
Programming Experience
10+
In a stored procedure, if I declare @myDate DateTime
and
set @myDate = '7/4/2005'

How do I determine if @myDate is a Tuesday?

or

How do I find out what DayOfWeek it is?

This is easy in VB.NET but I can't see how to do it in an sp.

In MSSQL, btw.
 

PelleH

Member
Joined
Jun 29, 2004
Messages
8
Programming Experience
5-10
Hi,

Check out the DATEPART function in sql server books online.

/Pelle
 

TomPhillips

Active member
Joined
Feb 24, 2005
Messages
33
Programming Experience
10+
DATEPART v. DATENAME

I used
if DATENAME(weekday, @myDate) = 'Tuesday' then ...

I wonder if
if DATEPART(day, @myDate) = 3 then ...
is more efficient (assuming Tuesday = 3)?
 
Top Bottom