Simple mysql statement, add x minutes to current time

Hello,
I have two fields

a time,
b time

I want to do an insert like this:

insert into table values (curtime(), curtime() + x minutes)

How do i do that?

Thanks!
scarab890Asked:
Who is Participating?
 
AlThePal7Connect With a Mentor Commented:
The ADDTIME() function was added in MySQL 4.1.1.   You could try

INSERT INTO costream_test2
VALUES (Curtime(), DATE_ADD(Now(), INTERVAL '1' MINUTE ))

The DATE_ADD function needs a DateTime value, so you have to use Now() instead of Curtime().
0
 
AlThePal7Commented:
You want something like this:

INSERT INTO test1 (a, b) VALUES (Curtime(), ADDTIME(Curtime(),"00:01:00"))

This will obviously add 1 minute to the current time for field b - just change the last string as required to add a different number of minutes.
0
 
scarab890Author Commented:
Hi,
Thanks for replying.

I had tried that before, but for some reason its not working, this is the table (exporting it):

CREATE TABLE costream_test2 (
  a time default NULL,
  b time default NULL
) TYPE=MyISAM;


This is what i ran:
INSERT INTO costream_test2
VALUES (Curtime( ) , ADDTIME(Curtime( ) , "00:01:00"))


But mysql is spitting out an error.

I am running version 3.23


Whats wrong?

Thanks!
0
 
scarab890Author Commented:
I dont reall understand why date_add has to be used....but I do understand that your answer works perfectly and I appreciate it, I am increasing the points and accepting your answer as without it I would have to join the mysql list etc and wait for an answer!

Thanks!
0
 
AlThePal7Commented:
Your welcome, glad I could help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.