Open In App

UTC_DATE() function in MySQL

Last Updated : 07 Oct, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
UTC_DATE() function in MySQL is used to check current Coordinated Universal Time (UTC) date. It returns the UTC date value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in string or numeric context. Syntax :
UTC_DATE
   OR
UTC_DATE()
Parameter : This method does not accept any parameter. Returns : It returns the current Coordinated Universal Time (UTC) date. Example-1 : Getting the current UTC date using UTC_DATE Function.
SELECT UTC_DATE as CurrUtcDate ;
Output :
CurrUtcDate
2020-10-01
Example-2 : Getting the current time using UTC_DATE Function in numeric format.
SELECT UTC_DATE + 0 as CurrUtcDate ;
Output :
CurrUtcDate
20201001
Example-3 : The UTC_DATE function can be used to set value of columns. To demonstrate create a table named DeliveryDetails.
CREATE TABLE DeliveryDetails (
DeliveryId INT AUTO_INCREMENT,
ProductId INT NOT NULL,
ProductName VARCHAR(20) NOT NULL,
Delivered_On DATE NOT NULL,
PRIMARY KEY(DeliveryId)
);
Here, we will use UTC_DATE function when a delivery will be completed. The value in Delivered_On column will be the value given by UTC_DATE Function.
INSERT INTO  
DeliveryDetails(ProductId, ProductName, Delivered_On)
VALUES
(101001, 'Asus ROG', CURRENT_DATE);
Now, checking the DeliveryDetails table :
SELECT * FROM DeliveryDetails;
Output :
DeliveryId ProductId ProductName Delivered_On
1 101001 Asus ROG 2020-10-01

Next Article
Article Tags :

Similar Reads