Updating date in sql
The function takes three arguments: mm refers to months, 3 refers to the number of months and Order Date is the DATETIME value. Up to this point, the examples have shown you how to modify a date/time value as you retrieve it from the database.As a result, three months will be added to the Order Date value when the query returns the value, as shown in the following results: As you can see, the new date is Aug. You can also use the DATEADD function to insert date/time data.
Transact-SQL (T-SQL) supports two important date/time functions -- DATEADD and DATEDIFF -- to enable you to easily perform these sorts of calculations.
For example, you might need to add or subtract a month from a specific date.
You can use the DATEADD function to perform this calculation.
The function specifies days (dd) for the first argument, -3 for the second argument and the Deliv Date column for the third argument.
This means that the function returned a date three days earlier than the original date and set the Deliv Date column to the new date, as shown in the following results: Part 1: Basics for working with DATETIME and SMALLDATETIME Part 2: Data conversions from date/time values to character types Part 3: Using datetime functions GETDATE, DATENAME and DATEPART Part 4: Using DATEADD and DATEDIFF to calculate datetime values Part 5: New datetime data types in SQL Server 2008 placeholder refers to its end date.