Combining a Date and a Time into a Date-and-Time Value : CONCAT « String « SQL / MySQL






Combining a Date and a Time into a Date-and-Time Value

       
mysql>
mysql>
mysql> SET @d = '2002-02-28';
Query OK, 0 rows affected (0.00 sec)

mysql> SET @t = '13:10:05';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @d, @t, CONCAT(@d,' ',@t);
+------------+----------+---------------------+
| @d         | @t       | CONCAT(@d,' ',@t)   |
+------------+----------+---------------------+
| 2002-02-28 | 13:10:05 | 2002-02-28 13:10:05 |
+------------+----------+---------------------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
    
    
    
  








Related examples in the same category

1.CONCAT(, [{, }...])
2.Use the CONCAT() and LEFT() functions to create registration codes for the employees.
3.Manipulate retrieved data from the Employees table.
4.Canonizing Not-Quite-ISO Date Strings
5.Add the setting NO_ZERO_IN_DATE to the SQL_MODE system variable.
6.To combine strings rather than pull them apart, use the CONCAT( ) function.
7.Concatenating Character Strings
8.Concatenation can be useful for modifying column values "in place."
9.Non-ISO results from the CONCAT( ) operation can be converted into ISO format three different ways as follows:
10.Generate Unique Sequential Numbers
11.Use Concat to create Initial for the name