PARSE Function - SQL


Overview


The PARSE function in SQL Server is used to convert a string representation of a date and/or time into a datetime or datetime2 data type. It supports parsing strings in various formats, providing flexibility in handling date and time values.

Example:

SELECT PARSE('2024-01-01 12:34:56' AS datetime2)

Syntax:

SELECT PARSE(string_value AS data_type [ USING culture ])

string_value is the string representation of the date and/or time that you want to convert into a datetime or datetime2 data type.

data_type specifies the target data type (datetime or datetime2) to which the string should be parsed.

culture (optional) specifies the culture whose format will be used for parsing. If not specified, the current session's language setting is used for parsing the date and time string.