Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 F_TABLE_DATE with DynamicYear

Author  Topic 

calvinfoo
Posting Yak Master

129 Posts

Posted - 2011-07-25 : 01:10:17
Hi Gurus,

I am using the F_TABLE_DATE, it works great.

Example:
F_TABLE_DATE ('2010', '2011')

Now I want to input a dynamic year:

select * from F_TABLE_DATE(
select max(year(holidayDate)) from holidays
,
select min(year(holidayDate)) from holidays
)


But it gives the following error:
Incorrect syntax near the keyword 'select'.

Please advise.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-25 : 01:20:58
select * from F_TABLE_DATE( (select min(year(holidayDate)) from holidays), (select max(year(holidayDate)) from holidays) )



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

calvinfoo
Posting Yak Master

129 Posts

Posted - 2011-07-25 : 01:25:00
Thanks!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-07-25 : 01:48:35
if you are using SQL 2005 / 2008

;with hdays as
(
select minholidayDate = min(holidayDate),
maxholidayDate = max(holidayDate)
from holidays
)
select DATE
from hdays
cross apply F_TABLE_DATE(minholidayDate, maxholidayDate)




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

calvinfoo
Posting Yak Master

129 Posts

Posted - 2011-07-25 : 05:14:36
Cross apply... this is something new to me. I'll look into this, thanks again khtan
Go to Top of Page
   

- Advertisement -