6_Built-in-Functions
6_Built-in-Functions
Fsoft Academy
1. Conversion Functions
3. String Functions
Conversion Functions
The Cast() function is used to convert a data type variable or data from one
data type to another data type.
The Cast() function provides a data type to a dynamic parameter (?) or a
NULL value.
14 114 - hh:mi:ss:mmm(24h)
- 20 or 120 ODBC canonical yyyy-mm-dd hh:mi:ss(24h)
- 21 or 121 ODBC canonical (with milliseconds) yyyy-mm-dd hh:mi:ss.mmm(24h)
Syntax:
GETDATE()
DATEPART(datepart, date)
Result:
Result:
Ex:
DECLARE @dt datetime; Result:
SET @dt = GETDATE();
SELECT @dt AS CurrentDate;
SELECT DATEADD(day, 30, @dt) AS AffterDate;
Result:
String Functions
Result:
String Functions
RTRIM, LTRIM, SUBSTRING, LEN, CHARINDEX, PATINDEX
Demo