By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,066 Members | 1,841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,066 IT Pros & Developers. It's quick & easy.

Can someone show me how I can output hrs:mins:secs in mySQL SELECT statement below?

P: 74
Here is what I have so far when use the DATE_ADD function in MySQL Workbench 6.3, but I have been struggling to output the hrs:mins:secs (you don't see the code for that output because I didn't write it here). I know that I can use INTERVAL HOUR_SECOND to display hrs:mins:secs but I don't understand how it works.


Expand|Select|Wrap|Line Numbers
  1. SELECT DATE_ADD('2017-01-26', INTERVAL 31 DAY) AS '31 Days'; 
  2.  


I know this SELECT statement above will output 31 days from the specified date indicated above, but what do I need to do to output the hrs:mins:secs along with the 31 days from the date in the SELECT statement?

Below is the output of how I would like it to be, but the hours:minutes:secs must be time corresponding to 31 days after the day indicated above in my SELECT statement.
Attached Images
File Type: png Step 4.PNG (1.2 KB, 69 views)
Jan 28 '17 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 100+
P: 589
Did you read the documentation for the date_add function? It has an example doing exactly what you want.
https://dev.mysql.com/doc/refman/5.5...ction_date-add

Here's another example.
http://www.w3schools.com/sql/func_date_add.asp
Jan 29 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.