mogabr
April 6, 2011, 5:14pm
1
hello all
i have 2 columns every column in the following format
column1
2011-04-01 11:39:54
column2
2019-02-03 00:00:00
i want get difference between above data as following
2 days 11:39
how to do so ?
i tried many functions but nothing works
please advice what is the query doing that ?
mogabr
April 6, 2011, 5:38pm
3
i have tried timediff() , datediff(), to_days(), timestampdiff()
all doesnt show what i want , i wand the difference how many days and hours:min
so i can update another column with these values
---------- Post updated at 02:38 PM ---------- Previous update was at 02:29 PM ----------
corona688:
What have you tried?
i have tried timediff() , datediff(), to_days(), timestampdiff()
all doesnt show what i want , i wand the difference how many days and hours:min
so i can update another column with these values
I suspect you're going to have to do it in bits, subtracting it and getting the parts you want piecemeal and piecing them together with concat.
mogabr
April 6, 2011, 5:48pm
5
in excel its very easy :)) i wonder why mysql dont do same
=TEXT(D2-C2,"d - h:mm")
can you give me example of such query ?
pludi
April 6, 2011, 7:45pm
6
Don't have a MySQL handy, but try something like this:
DATE_FORMAT(TIMESTAMPDIFF(MINUTES, column2, column1), '%d days %H:%i')
mogabr
April 7, 2011, 9:40am
7
i have tried above formula
the output is all like this
00 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:0000 days 00:00