Rasmus Bech
Rasmus Bech

Reputation: 84

php/sql select all that expires within 48 hours

I have a table with a field named creationdate, add 14 days to this value and you have the expiry date. (all in unix timestamps by the way, so 14 days would be creationtime + 1209600)

Now I need to construct a SELECT statement that will pick all rows from this table that are within 48 hours of this expiry date, but I don't know where to start.

Upvotes: 0

Views: 145

Answers (1)

BIOSTALL
BIOSTALL

Reputation: 1696

How about this? You get all where now is between 12 days and 14 days of the creation date:

SELECT
  *
FROM
  my_table
WHERE
  UNIX_TIMESTAMP() BETWEEN (creationtime + 1036800) AND (creationtime + 1209600)

Upvotes: 4

Related Questions