-1

I am trying to create an application that will expire in 30 days from the time of the product entry into database.

1: I know of timestamp and datetime. which of them do i used. 2: how do i minus the present time from the 30 days of the product expiration and then insert it to database.

user3368813
  • 47
  • 2
  • 7
  • For the first question, see: http://stackoverflow.com/questions/409286/datetime-vs-timestamp. For the second, use `DATE_SUB()`. – Barmar Apr 18 '14 at 22:05
  • I have put up an answer because i think i know what you are trying to do, but please put up some code of things you have tried. – Victory Apr 18 '14 at 22:06
  • my product has a closing date in 30 days. my question is how do i convert 30 days into time and then insert into mysql database via insert statements or php – user3368813 Apr 18 '14 at 22:15

1 Answers1

0

Assuming your date column is my_date like

CREATE TABLE `my_table` (
    `my_date` DATETIME
)

You can do something like the following to add timestamp 30 days in the future:

INSERT INTO `my_table` SET `my_date` = DATE_ADD(NOW(), INTERVAL 30 DAY);
Victory
  • 5,811
  • 2
  • 26
  • 45