The SQL DATEADD() function is used to add or subtract a time interval to a date.
SQL Functions
SQL Functions
SQL DAY
The SQL DAY() function is used to get the day (an integer in the range of 1 to 31) from a date expression.
To get the year from a date: SQL YEAR Function.
To get the month from a date: SQL Month Function.
To get the day from a date: SQL Day Function.
SQL MONTH
The SQL MONTH() function is used to get the month (an integer in the range of 1 to 12) from a date expression.
If you need to get the year from a date, you could use the SQL YEAR Function.
SQL YEAR
The SQL YEAR() function is used to get the year of a date expression.
To get the year from a date: SQL YEAR Function.
To get the month from a date: SQL Month Function.
To get the day from a date: SQL Day Function.
SQL TRIM
The SQL TRIM() function is used to remove the leading or trailing spaces of a string. Different databases have different writtings:
SQL Server | LTRIM(), RTRIM() |
Oracle | LTRIM(), RTRIM() |
MySQL | TRIM(), LTRIM(), RTRIM() |
In SQL Server or Oracle it doesn’t have Trim() function, we can combine LTrim() and RTrim():
RTRIM(LTRIM(str))
SQL MID
The SQL MID() function is used to get part of a string. It’s supported by MySQL, but not by MS SQL Server or Oracle. In SQL Server, Oracle databse, we can use SQL SUBSTRING or SQL SUBSTR instead.
SQL LOWER, SQL LCASE
The SQL LOWER, or SQL LCASE function is used to convert a string to lower case. In SQL Server, it uses the LOWER function.