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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 date function

Author  Topic 

ri16
Yak Posting Veteran

64 Posts

Posted - 2008-03-04 : 10:16:41
i have seen that date function which MVJ has created and its really very useful..

but i m getting error while selecting getdate() as @last_date in that function

SELECT
distinct date FROM
dbo.F_TABLE_DATE('1/1/1999', getdate()) AS Date

error is : Incorrect syntax near 'getdate'

what's mistake?

can anyone help me?

thanks in advance.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-04 : 10:24:32
[code]Declare @dt datetime
set @dt = GetDate()

SELECT
distinct date FROM
dbo.F_TABLE_DATE('1/1/1999', @dt) AS Date [/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

ri16
Yak Posting Veteran

64 Posts

Posted - 2008-03-04 : 10:54:54
Thanks Harsh.

Got it!!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-03-04 : 11:05:11
Bote that you cant directly pass getdate() as parameter to a function or procedure

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-03-05 : 15:24:31
quote:
Originally posted by madhivanan

Bote that you cant directly pass getdate() as parameter to a function or procedure


Did that change with 2005? I'm able to pass GETDATE() or CURRENT_TIMESTAMP directly to function without issue..
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-03-05 : 15:30:07
Looks like they did change it with 2005, probably to support cross apply.

It does not work in SQL 2000, so this was probably posted on the wrong forum.


CODO ERGO SUM
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-03-06 : 08:05:21
quote:
Originally posted by Lamprey

quote:
Originally posted by madhivanan

Bote that you cant directly pass getdate() as parameter to a function or procedure


Did that change with 2005? I'm able to pass GETDATE() or CURRENT_TIMESTAMP directly to function without issue..


Yes it is changed in SQL Server 2005
Also you can very well use GETDATE() inside UDF

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -