user979626
user979626

Reputation: 421

mysql insert(working with expiration date)

I was wondering how insert now() + 3 days into a mysql insert.

kinda like this mysql_query(INSERT INTO what_ever ('','',now(), now() + 3 days) Ignore if this code doesn't work it just and example.

I was wondering how I can do this. I want to add an expiration time so when users log in and its on that date or past it will automatically remove the item. I don't need help removing I just need help adding it the date to the now function.

Upvotes: 2

Views: 2200

Answers (2)

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115530

Not now() + 3 days. Use:

now() + INTERVAL 3 DAY

Upvotes: 4

planestepper
planestepper

Reputation: 3297

Use MySQL's DATEADD function:

INSERT INTO what_ever ('', '', now(), DATE_ADD(NOW(), INTERVAL 3 DAY));

Upvotes: 3

Related Questions