chandru_244
January 11th, 2006, 05:46 AM
Hi ,
Follwoing is a simple function to retreive a date basis a criteria...
Logic :
If Date is not null in table A return Date from Table A
else retrun Getdate().
Following the function
Create Function RetreiveDate()
Returns DateTime
As
Begin
Declare @ReqdDate DateTime
Select @ReqdDate = Operating_Date From TableA
If @ReqdDate Is Null
Begin
Set @ReqdDate = getdate()
End
Return @ReqdDate
End
When i try to compile the above function it throws the following error
Server: Msg 443, Level 16, State 1, Procedure Sp_Acc_GetOperatingDate, Line 10
Invalid use of 'getdate' within a function.
Y is this happening..
is there any way to use Getdate inside a function
Tx in advance
Rgds,
Chandru
Follwoing is a simple function to retreive a date basis a criteria...
Logic :
If Date is not null in table A return Date from Table A
else retrun Getdate().
Following the function
Create Function RetreiveDate()
Returns DateTime
As
Begin
Declare @ReqdDate DateTime
Select @ReqdDate = Operating_Date From TableA
If @ReqdDate Is Null
Begin
Set @ReqdDate = getdate()
End
Return @ReqdDate
End
When i try to compile the above function it throws the following error
Server: Msg 443, Level 16, State 1, Procedure Sp_Acc_GetOperatingDate, Line 10
Invalid use of 'getdate' within a function.
Y is this happening..
is there any way to use Getdate inside a function
Tx in advance
Rgds,
Chandru