0

It is possible to auto-increment datetime which I parse from daterangepicker to add AddDays(7) and then insert it to DB?

string strValue = Page.Request.Form["daterange"];
string strValue2 = Page.Request.Form["daterange2"];

DateTime myDate = DateTime.Parse(strValue);
DateTime myDate2 = DateTime.Parse(strValue2);

queryStr = "INSERT INTO `wp_reservations` ( `arrival`, `departure`, `user`, `name`, `email`, `country`, `approve`, `room`, `roomnumber`, `number`, `childs`, `price`, `custom`, `customp`, `reservated`) VALUES ('" + strValue + "INTERVAL 7 DAY', '" + strValue2 + "', 0, '" + DropDownList1.SelectedItem.Text + "', '" + emailValue + "', 'SI', '" + DropDownList2.SelectedValue + "', '" + DropDownList3.SelectedValue + "', '1', 10, 0, '0;0', '', '', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt") + "');";
dakab
  • 5,379
  • 9
  • 43
  • 67
Glados
  • 1
  • 2

2 Answers2

1

You can use

DATE_ADD(NOW(), INTERVAL 7 DAY) in insert query

er_chin
  • 21
  • 3
0

If u want to do this in code see Datetime in C# add days

U can also do it in DAO query see DATEADD (Transact-SQL)

Community
  • 1
  • 1
Esty
  • 1,882
  • 3
  • 17
  • 36