Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stuff
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Re: Stuff
Miscellaneous
Thread ID:
00656549
Message ID:
00656553
Views:
7
>Hi All:
> I am trying to replace only a year value in a datetime filed on a SQL 7.0 table with a current year. For example, if the value is 05/27/2001, I want this to be 05/27/2002. Is there a function in SQL 7.0 (like "STUFF" in VFP) that could help me accomplish my goal.
>
You can use Datepart() and Dateadd() functions as follows
DECLARE @dt datetime
SET @dt = '05/27/2000'
SELECT @dt, DATEADD(Year,  2002 - DATEPART(year, @dt), @dt)

-- Update
UPDATE mytable SET DTfield = DATEADD(Year,  2002 - DATEPART(year, DTfield ), DTfield )
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform