Loading

MySQL Date Or Time Function Part-5

In MySQL Date Or Time Function Part-5 we will discuss about the LOCALTIME Function, LOCALTIMESTAMP Function, MAKEDATE Function, MAKETIME Function, MICROSECOND Function, MINUTE Function, MONTH Function, MONTHNAME Function, NOW Function.

LOCALTIME Function:- LOCALTIME Function is used for returning the current date and time. Return format will be YYYY-MM-DD HH-MM-SS” (string) or as YYYYMMDDHHMMSS.uuuuuu (numeric)

Syntax:- LOCALTIME()

Example:-

SELECT LOCALTIME();

Output:- 2023-02-12 09:37:02

LOCALTIMESTAMP Function:- LOCALTIMESTAMP Function is used for returning the current date and time. The date and time format will be “YYYY-MM-DD HH-MM-SS” (string) or “YYYYMMDDHHMMSS.uuuuuu” (numeric)

Syntax:- LOCALTIMESTAMP()

Example:-

SELECT LOCALTIMESTAMP();

Output:- 2023-02-13 14:59:17

 MAKEDATE Function:- MAKEDATE Function is used for returning the date from a given year and a number of days value. The number of days must be greater than zero. otherwise, it returns NULL.

Syntax:- MAKEDATE(Year, number of days)

Example:-

SELECT MAKEDATE(2023, 44);

Output:- 2023-02-13

MAKETIME Function:- MAKETIME Function is used for returning a time value from given hour, minute, and second values.

Syntax:- MAKETIME(hour, minute, second)

Example:-

SELECT MAKETIME(08, 39, 40);

Output:- 08:39:40

MICROSECOND Function:- MICROSECOND Function is used for returning the microsecond part from a given date and time value. the range of microsecond value can be 0 to 999999

Syntax:- MICROSECOND(datetime)

Example:-

SELECT MICROSECOND(“09:45:40.000345”);

Output:- 345

MINUTE Function:- MINUTE Function is used for returning the minute part from the given date-time.

Syntax:- MINUTE (datetime)

Example:-

SELECT MICROSECOND(“09:45:40.000345”);

Output:- 45

 MONTH Function:- MONTH Function is used for returning the month part from the given date and time.

Syntax:- MONTH(datetime)

Example:-

SELECT MONTH(“2023-02-13 08:50:34”);

Output:- 2

MONTHNAME Function:- MONTHNAME Function is used for returning the month name from the given date and time.

Syntax:- MONTHNAME(datetime)

Example:-

SELECT MONTHNAME(“2023-02-13 08:53:44”);

Output:- February

SELECT MONTHNAME(CURDATE());

NOW Function:- NOW Function is used for returning the current server date and time. The date and time format will be “YYYY-MM-DD HH-MM-SS” (string) or as YYYYMMDDHHMMSS.uuuuuu (numeric).

Syntax:- NOW()

Example:-

SELECT NOW();

Output:- Current server date and time like 2023-02-13 15:29:01

Read Also:-

MySQL Date Or Time Function Part-1
MySQL Date Or Time Function Part-2
MySQL Date Or Time Function Part-3
MySQL Date Or Time Function Part-4
MySQL Date Or Time Function Part-6
MySQL Date Or Time Function Part-7
MySQL Date Or Time Function Part-8

Read more detail about MySQL Date Or Time Function manual

Share with:


Leave a Reply

Connect with:

z35W7z4v9z8w
Verified by ExactMetrics