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
 date return from stored procedure...help!

Author  Topic 

billq
Starting Member

3 Posts

Posted - 2006-07-01 : 11:48:36
Hi,

I created this stored procedure to add 90 days to the current date, and return the new date:

CREATE PROCEDURE Get90Days
AS
SELECT DATEADD(day, 90, current_timestamp) AS "RETURNDAYS"

The procedure above returns this result:

2006-09-29 07:31:14.477

I need this procedure to return the date, only, like this:

09-29-2006

I tried using the convert switch to reformat the result to the date only, but have not been successful.

What does this stored procedure need to look like to return just the date, like this:

09-29-2006

I appreciate your help.
Thanks,
Bill

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-01 : 11:50:25
do this instead
SELECT dateadd(day, datediff(day, 0, current_timestamp), 90) AS "RETURNDAYS"



KH

Go to Top of Page

billq
Starting Member

3 Posts

Posted - 2006-07-01 : 11:59:42
Hi Khtan,

That works well, but it still returns the time as:

00:00:00.000

Is there a method I can use to eliminate returning the time information altogether?

Thanks,
Bill
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-07-01 : 13:09:07
you have to convert it to varchar.
look up CAST/CONVERT in BOL.

But this is a presentation layer issue. it's not a job for a database.


Go with the flow & have fun! Else fight the flow
Go to Top of Page

billq
Starting Member

3 Posts

Posted - 2006-07-01 : 15:00:36
Hi Spirit1,

Thank you!

Bill
Go to Top of Page
   

- Advertisement -