Biribu
Biribu

Reputation: 3833

Add 2 weeks to a date SQL

I have to insert a date in a DB and I want to set the end date 2 weeks after that date.

How can I make it?

in my select, I guess there is needed something like:

insert into table values (current_Date, current_Date+2weeks) where....

But I don't know how to do it.

Upvotes: 6

Views: 20332

Answers (1)

hangman
hangman

Reputation: 875

for mysql

INSERT INTO tbl(fromdate,todate) values (now(), DATE_ADD(now(),INTERVAL 2 WEEK))

for sql server

 INSERT INTO tbl(fromdate,todate) values( current_timestamp, DATEADD(week,2,current_timestamp))

Upvotes: 22

Related Questions