-
Problem with AddTime
Hi there everybody, I hope your help.
My table:
Code:
myDateMySql myTimeMySql myTotMySql_min
01/01/2010 16.25 30
I need this output:
Try this code, but I have error:
Code:
ADDTIME(CONCAT(STR_TO_DATE(`myDateMySql`,'%d/%m/%Y'), ' ', `myTimeMySql`), `myTotMySql_min`)
[Err] 1292 - Truncated incorrect time value: '92'
Can someone help me?
Thanks in advance.
Chevy
-
http://dev.mysql.com/doc/refman/5.1/...ction_date-add
Code:
DATE_ADD(myDateMySql, INTERVAL myTimeMySql MINUTE)
-
why use a function? just do the date math like this --
Code:
SELECT myDateMySql
, myTimeMySql + INTERVAL myTotMySql_min MINUTE AS newtime
FROM daTable
-
Hmm, so the 30 in the example data is the myTotMySql_min column value?
Does that mean date and time are stored in separate columns?
That might give some problems when going past midnight, wouldn't it?
-
hi there, thanks for replying.
I try two suggestions but:
50 = myTotMySql_min
16.25 = myTimeMySql
01/01/2010 = myDateMySql
I have this output:
2010-01-01 00:50:00
and not this:
2010-01-01 17:15:00
:confused:
PHP Code:
SELECT myDateMySql
, myTimeMySql + INTERVAL myTotMySql_min MINUTE AS newtime
FROM daTable
DATE_ADD(myDateMySql, INTERVAL myTimeMySql MINUTE)
-
My table:
myTotMySql_min = 50 (int 10)
myTimeMySql = 16.25 (varchar 255)
myDateMySql = 01/01/2010 (date)
I try this code:
PHP Code:
SELECT myDateMySql
, myTimeMySql + INTERVAL myTotMySql_min
MINUTE AS newtime
FROM daTable
SELECT myDateMySql
, TIME_FORMAT(myTimeMySql,'%H:%i') + INTERVAL myTotMySql_min MINUTE
AS newtime
FROM daTable
Output:
Code:
myDateMySql newtime
2010-01-01 (Null)
And this code:
PHP Code:
SELECT
DATE_ADD(myDateMySql, INTERVAL
myTimeMySql MINUTE) AS newtime FROM daTable
SELECT
DATE_ADD(myDateMySql, INTERVAL
TIME_FORMAT(myTimeMySql,'%H:%i') MINUTE) AS newtime
FROM daTable
Output:
Code:
newtime
2010-01-01 00:16:00
Output:
Code:
newtime
2010-01-01 00:00:00
:sick:
-
Code:
SELECT myDateMySql
, myTimeMySql
, myTotMySql_min
, ADDDATE(CONCAT(`myDateMySql`, ' '
, `myTimeMySql`)
, INTERVAL myTotMySql_min MINUTE) as t
FROM datable
Output:
t= '2010-01-01 17:15:00'
:)