
- You are not logged in. | Login
January 18, 2007 12:27 pm
- franzkafka
- Member


Trouble with NOW()
I use such query:
INSERT INTO `table` (user_id, start_time, end_time) VALUES
(1, NOW() - 100, NOW() - 50),
(2, NOW()-51, NOW() - 50),
(4, NOW()-100, NOW() - 52)
Execute it three times and get as follows:
id user_id start_time end_time
1 1 2006-12-22 12:57:06 2006-12-22 12:57:56
2 2 2006-12-22 12:57:55 2006-12-22 12:57:56
3 4 2006-12-22 12:57:06 2006-12-22 12:57:54
4 1 2006-12-22 12:57:11 0000-00-00 00:00:00
5 2 0000-00-00 00:00:00 0000-00-00 00:00:00
6 4 2006-12-22 12:57:11 2006-12-22 12:57:59
7 1 2006-12-22 12:57:48 0000-00-00 00:00:00
8 2 0000-00-00 00:00:00 0000-00-00 00:00:00
9 4 2006-12-22 12:57:48 0000-00-00 00:00:00
mysql 4.0.28
What's the problem with query?
January 18, 2007 12:29 pm
- phppat
- Member


Re: Trouble with NOW()
Tell me please, what do you want to get when NOW()-100?
PHP monster
January 18, 2007 12:32 pm
- franzkafka
- Member


Re: Trouble with NOW()
phppat, the current time - 100 seconds. I can't do this, can I?
January 18, 2007 12:36 pm
- franzkafka
- Member


Re: Trouble with NOW()
Hm, let's suppose that it shouldn't work, but why we get these results while insertion? 
January 18, 2007 12:40 pm
- phppat
- Member


Re: Trouble with NOW()
Have you read a manual? Go and read about MySQL working and function for working with date. By the way, here on the forum there is an article about working with date find it and read!!
what does NOW() function return?
PHP monster
January 18, 2007 12:43 pm
- franzkafka
- Member


Re: Trouble with NOW()
phppat,
1. NOW() returns - date in format 0000:00:00 00-00-00
2. NOW() +- digit - date in yyyymmddhhmmss format



