Update Date between two Dates in SQL Server

Last Reply 5 days ago By SUJAYS

Posted 6 days ago

How to update date between two date ?

 

Eg 01-july-2017 and 10-07-2017  Iwant to change all the date between these date to 20-07-2017

Posted 6 days ago

Hi SUJAYS,

As per your query i have create the sample.If you have any doubt please revert me back.Below is the given sample.

SQL

DECLARE  @DATES TABLE
(Dates DATETIME)

INSERT INTO @DATES VALUES('07-01-2017')
INSERT INTO @DATES VALUES('07-02-2017')
INSERT INTO @DATES VALUES('07-03-2017')
INSERT INTO @DATES VALUES('07-04-2017')
INSERT INTO @DATES VALUES('07-05-2017')
INSERT INTO @DATES VALUES('07-17-2017')
INSERT INTO @DATES VALUES('07-14-2017')
INSERT INTO @DATES VALUES('07-20-2017')
INSERT INTO @DATES VALUES('07-25-2017')

UPDATE  @DATES 
SET Dates ='07-20-2017' 
WHERE Dates BETWEEN '07-01-2017' AND '07-10-2017'

Output

   Dates
7/20/2017 0:00
7/20/2017 0:00
7/20/2017 0:00
7/20/2017 0:00
7/20/2017 0:00
7/17/2017 0:00
7/14/2017 0:00
7/20/2017 0:00
7/25/2017 0:00

Posted 5 days ago

I got the answer

Update sample Set EntryDate '30-Jul-2017' where EntryDate between '01-jul-2017' and '10-Jul-2017'

 

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html?aff_id=108