March 5, 2006 at 12:18 pm
I know this can be done in mySQL can it be done in sql server?
i have dates in datetime format, but it would be very useful if i could output them in a format that includes the day
ive had a look on the net but cant seem to find it.
sorry for the newb question!
edit
scrap that. just found a work around....this one just adds weekends along with the name of the day. its an easy hack to get it what i want to do.
CREATE TABLE WeekEndsAndHolidays (DayOfWeekDate datetime, DayName char(3))
GO
SET NOCOUNT ON
DECLARE @FirstSat datetime, @x int
SELECT @FirstSat = '1/3/2004', @x = 1
--Add WeekEnds
WHILE @x < 52
BEGIN
INSERT INTO WeekEndsAndHolidays(DayOfWeekDate, DayName)
SELECT DATEADD(ww,@x,@FirstSat), 'SAT' UNION ALL
SELECT DATEADD(ww,@x,@FirstSat+1), 'SUN'
SELECT @x = @x + 1
END
SET NOCOUNT OFF
GO
March 5, 2006 at 7:47 pm
You can use the hack, or you can use the functionality built into SQL Sever...
SELECT DATENAME(dw,GETDATE())+' '+CONVERT(CHAR(11),GETDATE(),106)
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply