TIMEX
TIMEX

Reputation: 272264

How do I write this MySQL Query? (datetime)

Suppose I have a DateTime field called "time_before"

I want to insert a datetime that is 1 hour before the now() time.

INSERT INTO mytable(time_before) VALUES(now()-3600 seconds)...something like this, right?

Upvotes: 1

Views: 282

Answers (2)

Your Common Sense
Your Common Sense

Reputation: 157981

That's wrong database design. why not to insert just current datetime? All calculations must be done at select time.

Upvotes: 0

Tatu Ulmanen
Tatu Ulmanen

Reputation: 124868

INSERT INTO mytable(`time_before`) VALUES(NOW() - INTERVAL 1 HOUR)

Upvotes: 2

Related Questions