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

Syntax:

SELECT SQLHTTP.net.DateTime2_To_String ( @DateTime2, @Format )

Arguments:

Name Type Description
@DateTime2 datetime Value to format
@Format varchar(MAX) A Custom Date and Time Format string

Return Type:

varchar(max)

Remarks:

Similar to SQL Server’s FORMAT function using lesser precision but with compatibility with SQL Server 2008.

Sample Usage:

See Also: