December 16, 2011 at 9:59 am
Anyone know how to do this. I've done it in the past however forgot which sys table i used for generating this.
create table #date
(
dayOfYear datetime
)
insert into #date ( dayOfYear )
select???????????
December 16, 2011 at 10:12 am
here's a copy of mine named TallyCalendar, which generates dates from the SQL beginning of time (1900-0101) to 100 years in the future compared to today.
the advantage is i've added a lot of things based on experience, like Daylight Savings time, ISOweeks, integers for Day/Month/Year, Julian dates, and more.
i'm also generating alot of other columns, and include stuff like IsWeekday,IsHoliday, etc, which can be helpful for calculating business days.
see if this is helpful for you:
TallyCalendar_Complete_With_DST.txt
Lowell
December 16, 2011 at 10:20 am
Wow.
Even the requirement of knowing whether or not the moon is gibbous is catered for 🙂
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
December 16, 2011 at 11:16 am
Phil Parkin (12/16/2011)
Wow.Even the requirement of knowing whether or not the moon is gibbous is catered for 🙂
Adding the moon thing came about with the question "when is the next Friday the thirteenth , or the next Halloween that is also a full moon."
well, now that it's in the table, it's trivial to get.
I've actually been playing with putting the surise/sunset in there too, so you just pass latitude and longitude, but i can't quite get it to work yet.
Once I know I've got that working right, i'll add that too.
Lowell
December 24, 2011 at 3:15 pm
captcooldaddy (12/16/2011)
Anyone know how to do this. I've done it in the past however forgot which sys table i used for generating this.create table #date
(
dayOfYear datetime
)
insert into #date ( dayOfYear )
select???????????
To answer the question without a Calendar table...
DECLARE @DesiredYear CHAR(4);
SELECT @DesiredYear = '2011'
SELECT DayOfYear = DATEADD(dd,Number,@DesiredYear)
INTO #Date
FROM master.dbo.spt_Values
WHERE Type = 'P'
AND Number >= 0
AND Number < DATEDIFF(dd,@DesiredYear,DATEADD(yy,1,@DesiredYear))
--Jeff Moden
Change is inevitable... Change for the better is not.
December 24, 2011 at 5:37 pm
Lowell (12/16/2011)
here's a copy of mine named TallyCalendar, which generates dates from the SQL beginning of time (1900-0101) to 100 years in the future compared to today.the advantage is i've added a lot of things based on experience, like Daylight Savings time, ISOweeks, integers for Day/Month/Year, Julian dates, and more.
i'm also generating alot of other columns, and include stuff like IsWeekday,IsHoliday, etc, which can be helpful for calculating business days.
see if this is helpful for you:
Lowell -Fantastic amount of work, Thanks for sharing with all
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply