Day of Week function in TSQL
Posted on 2004-04-08
I'm attempting to write a function that will provide me with next day of a given date. For instance, if the date I have is April 8 2004 (thursday) and I need the first monday following that date.
The problem I've run into is that I can't seem to find a way of detecting what the weekday of a date is.
I've gone this far...
Create Function dbo.GetNextDay(@SDate DateTime, @Day Int)
Declare @Ret DateTime,
--HERE I NEED TO SET @DAYDIF TO THE NUMBER OF DAYS BETWEEN THE CURRENT DAY AND THE DAY I'M LOOKING FOR
Set @Ret = DateAdd(@SDate,@DayDif)
Thanks in advance.