473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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

74 64KB
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, 113 views)
Jan 28 '17 #1
1 1774
RonB
589 Expert Mod 512MB
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

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

Similar topics

3
by: hokieghal99 | last post by:
Hi, I'd like to get user input from an html form into a mysql select statement. Here's where I'm stumped: $result = mysql_query("SELECT * FROM dept WHERE notes LIKE '%search-string%'",$db); ...
8
by: worldcyclist | last post by:
Hey folks! I tried hunting for a MySQL specific NG and didn't find one but I did see that MySQL questions get asked here. If this isn't appropriate and you know of an appropriate NG then that...
11
by: Jeff Sandler | last post by:
I need a MySQL select statement as part of a PHP script. I want to find rows where a certain column either starts with or equals a user-supplied string. The string will be 1 or more characters in...
5
by: RioRanchoMan | last post by:
I have a forum table where the field Forum_ID of the first thread corresponds to itself in the field Forum_Ancestor, and 0 (zero) for the field Forum_Parent when it is the first topic in a thread:...
3
by: Lucky | last post by:
hi guys! it's very very simple question for you mighty sql DBAs. but very hard for a developer like me who is very very new to MS SQL. anyways the problem is i want to use one SPs out to in...
2
by: bhanab | last post by:
Hello, Please can someone help me with this select statement? How do I get the statement to keep the week number static? ie if there are no values then it should show up as NULL, zero or just stay...
3
by: Andreas | last post by:
Hi, I am bloody amateure and I was wondering if someone could help me edit the statement below so it groups the field SCDMASTER.SCTY_CLASS_CODE and creates one field called "total balance"...
1
by: bob1660 | last post by:
I am new to PHP and MYSQL. I have a Database table with 4 field. FirstName, LastName, DateofBirth and MemberNumber. I would like to have a form where a user can fill in the FirstName, LastName and...
3
by: sithlordkyle | last post by:
Hopefully I can explain this correctly. I am trying to take a MySQL select statement, get the output into a list, then upload that list back to the MySQL server. cursor.execute("SELECT stuff FROM...
4
by: yashuaking | last post by:
I have a MYSQL dynamic Pivoting prepared statement that works perfectly in MYSQL commandline and Workbench but when I run the code in VB.NET it gives Fatal Error. This is my code: SET @sql =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.