5.10.1 Problem
You want to produce a combined date-and-time value from separate date and time values.
5.10.2 Solution
Concatenate them with a space in between.
5.10.3 Discussion
Combining a date value and a time value to produce a date-and-time value is just a matter of concatenating them with a space in between:
mysql> SET @d = '2002-02-28'; mysql> SET @t = '13:10:05'; mysql> SELECT @d, @t, CONCAT(@d,' ',@t); +------------+----------+---------------------+ | @d | @t | CONCAT(@d,' ',@t) | +------------+----------+---------------------+ | 2002-02-28 | 13:10:05 | 2002-02-28 13:10:05 | +------------+----------+---------------------+
Using the mysql Client Program
Writing MySQL-Based Programs
Record Selection Techniques
Working with Strings
Working with Dates and Times
Sorting Query Results
Generating Summaries
Modifying Tables with ALTER TABLE
Obtaining and Using Metadata
Importing and Exporting Data
Generating and Using Sequences
Using Multiple Tables
Statistical Techniques
Handling Duplicates
Performing Transactions
Introduction to MySQL on the Web
Incorporating Query Resultsinto Web Pages
Processing Web Input with MySQL
Using MySQL-Based Web Session Management
Appendix A. Obtaining MySQL Software
Appendix B. JSP and Tomcat Primer
Appendix C. References