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 2000 Forums
 SQL Server Development (2000)
 UDF Returns Date

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2006-06-22 : 15:49:20
I'm working on a UDF that returns a data, but is broken up.

...
Returns Date
SET @RefDay = 1
SET @RefMonth = 12
SET @RefYear = 2003

Not sure, how to do it...
RETURN @RefMonth/@RefDay/@RefYear

How can I return 12/1/2003?

X002548
Not Just a Number

15586 Posts

Posted - 2006-06-22 : 16:40:38
DECLARE @Date datetime
SET CONVERT(datetime,@RefDay+'/'+@RefMonth+'/'+@RefYear)
RETURN @Date

????


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-06-22 : 18:25:14
Is that T-SQL Brett ???

...
RETURN(
SELECT DATEADD(YEAR,@RefYear,DATEADD(MONTH,@RefMonth,DATEADD(DAY,@RefDay,0))
)

Edit. Sorry I must have been drunk or something...

Edit2.
Thread 22339 !?!? Khtan?, how?!

rockmoose
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-22 : 19:00:24
You can also take a look here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=22339


KH

Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-06-22 : 20:14:11
quote:
Originally posted by rockmoose
...Edit2.
Thread 22339 !?!? Khtan?, how?!

rockmoose



I have a link to 22339 in the "Converting Year, Month, and Day to DateTime" section in the link below, plus I recently posted on that thread. I have been trying to assemble the answers to many of the typical date/time questions on that link as a "help yourself" resource. I went through the whole Script Library looking for posts about date/time and linked to that post and many others.

Date/Time Info and Script Links
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64762





CODO ERGO SUM
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-06-22 : 20:29:16
"I went through the whole Script Library"


Did you see the post about dates and excel on joel?
I enjoyed it. "My First BillG Review"


rockmoose
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-06-23 : 12:23:51
You must have been drunk? What the hell is this that I posted...I need to test more...I have no time on my hands right now...

Beware of DB2 OS/390...it leads...to the dark side...


quote:
Originally posted by X002548

DECLARE @Date datetime
SET CONVERT(datetime,@RefDay+'/'+@RefMonth+'/'+@RefYear)
RETURN @Date

????


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-06-23 : 16:13:35
Don't flirt with the dark side.
Only meet on neutral csv ground.

rockmoose
Go to Top of Page
   

- Advertisement -