MySQL – Functions to get current date and time

You may often need to do some data filters based on the current date and time. In MySQL you can use the system functions available to get current date and time.

Refer the following examples.

1 Get current date

SELECT CURRENT_DATE() AS today_date

or

SELECT CURDATE() AS today_date

The result is

2017-11-20

2 Get current time

SELECT CURRENT_TIME() AS today_time

or

SELECT CURTIME() AS today_time

The result is

08:36:29

3 Get Current Date and time

SELECT NOW() AS today_date_time

The result is

2017-11-20T08:36:29Z
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s