SUBDATE() Examples – MySQL

In MySQL, you can use the SUBDATE() function to subtract a specified amount of time from a date. For example, you could use it to subtract 10 days from a given date. You can specify whether to subtract days, weeks, months, quarters, years, etc. You can also subtract a time value, such as seconds, microseconds, etc.

When using the first syntax listed below, the SUBDATE() function is a synonym for the DATE_SUB() function (similar to how ADDDATE() is a synonym for DATE_ADD() when using the same syntax).

Continue reading

DATE_SUB() Examples – MySQL

In MySQL, you can use the DATE_SUB() function to subtract a specified amount of time from a date. For example, you can use it to subtract 7 days from a given date. You can specify whether to subtract days, weeks, months, quarters, years, etc. You can also subtract a time value, such as seconds, microseconds, etc.

This function is similar to DATE_ADD(), except that it subtracts from a date instead of adds to it.

Continue reading

DATE_ADD() Examples – MySQL

In MySQL, you can use the DATE_ADD() function to add a specified amount of time to a date. For example, you could use it to add 5 days to a given date. You can specify whether to add days, weeks, months, quarters, years, etc. You can also add a time value, such as seconds, microseconds, etc.

This article contains examples that demonstrate how the DATE_ADD() function works.

Continue reading

ADDDATE() Examples – MySQL

In MySQL, you can use the ADDDATE() function to add a specified amount of time to a date. For example, you could use it to add 10 days to a given date. You can specify whether to add days, weeks, months, quarters, years, etc. You can also add a time value, such as seconds, microseconds, etc.

The ADDDATE() function is a synonym for the DATE_ADD() function (they both do the same thing) when using the first syntax listed below.

This article contains examples to demonstrate usage of the ADDDATE() function.

Continue reading

SYSUTCDATETIME() Examples in SQL Server (T-SQL)

In SQL Server, the T-SQL SYSUTCDATETIME() function is used to return the current UTC time (Coordinated Universal Time). UTC time is the primary time standard by which the world regulates clocks and time.

The return value of the SYSUTCDATETIME() function is derived from the computer on which the instance of SQL Server is running. The time zone is not included, and it is returned as a datetime2 value. The fractional second precision specification has a range from 1 to 7 digits. The default precision is 7 digits.

SYSUTCDATETIME() does the same thing that GETUTCDATE() does, except that it returns a higher fractional precision. As mentioned,  SYSUTCDATETIME() returns a datetime2 value, whereas the GETUTCDATE() function returns a datetime value.

Continue reading

GETUTCDATE() Examples in SQL Server (T-SQL)

When using SQL Server, you can use the T-SQL GETUTCDATE() function to return the current UTC time (Coordinated Universal Time). UTC time is the primary time standard by which the world regulates clocks and time.

The return value of the GETUTCDATE() function is derived from the computer on which the instance of SQL Server is running. The time zone is not included, and it is returned as a datetime value.

Continue reading