Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 986
Biribu Avatar asked Nov 12 '13 09:11

Biribu


1 Answers

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))
like image 148
hangman Avatar answered Oct 29 '22 19:10

hangman