0 votes
1 view
in SQL by (30.7k points)

Can anyone tell me how to convert string to date in the SQL server?

1 Answer

0 votes
by (72.4k points)
edited by

We can convert string to date format either by using CAST or CONVERT functions in the SQL server. Here are the examples to use CAST AND CONVERT functions to convert strings to date format:

SELECT CAST (’07-05-20’ as date) as String_to_date;

SELECT CONVERT (DATETIME, ’07-05-20’, 103) as String_to_date1;

SELECT PARSE (’07-05-20’ as date) as String_to_date2;

In the above SQL query using CONVERT function, 103 is a style number for a particular date format.

You can go through this SQL Tutorial to learn more about DateTime conversions.

Related questions

0 votes
1 answer
asked May 6 in SQL by Sudhir_1997 (30.7k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...