DateTime2_To_String
Converts a datetime2 value to a string using a given custom date and time format.
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.DateTime2_To_String ( @DateTime2, @Format )
Name | Type | Description |
---|---|---|
@DateTime2 | datetime | Value to format |
@Format | varchar(MAX) | A Custom Date and Time Format string |
varchar(max)
Similar to SQL Server’s FORMAT function using lesser precision but with compatibility with SQL Server 2008.
1 2 3 |
SELECT SQLHTTP.net.DateTime2_To_String(SYSDATETIME(), 'yyyy-MM-ddTHH:mm:ss.fff') |
1 2 3 4 |
--------------------------------- 2017-11-21T14:37:03.380 |