Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 1st, 2006, 10:37 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Return date only...I need your help!

Hi,

I created this stored procedure in SQL 2000 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"

Run today, July 1, 2006, 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 but have not been successful.

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

09-29-2006

Thanks,
Bill


 
Old July 1st, 2006, 12:58 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why would you return a VARCHAR? You can't sort varchar dates, unless thery are stored yyyy-mm-dd.

CREATE PROCEDURE Get90Days
AS
SELECT CONVERT(VARCHAR(10), DATEADD(day, 90, GETDATE()), 110) ReturnDays

 
Old July 1st, 2006, 01:56 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Peso,

Thank you! This has been haunting me!

I want to return a vchar to load into a form, so the result does not have to be sorted.

Thanks, Peso, again for your help!
Bill





Similar Threads
Thread Thread Starter Forum Replies Last Post
Funny date return needelp Access VBA 3 September 19th, 2006 11:37 PM
copy date values between date controls Alcapone Javascript How-To 1 April 13th, 2006 03:13 AM
How to give Date format while entering date Subuana Beginning VB 6 4 March 17th, 2006 07:25 AM
DTS Import ( Date string to Date field) gfowajuh SQL Server 2000 1 September 30th, 2003 06:28 AM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.