How do I convert data that is in text to date in MySQL?
The data I have is like this
20210422
20210423
I want the data in this format
2021-04-22
CodePudding user response:
This depends on what kind of database you are using, and a quick google search should turn up the proper conversion function for your DBMS. For example, MS SQL date conversion is done via CAST and CONVERT functions: CAST and CONVERT
CodePudding user response:
I guess here there is some misunderstanding between date-storage and date-representation, but could you please try(for MS SQL Server)
DECLARE @InDate1 DATE='20210422';
SELECT @InDate1 AS ORIGG,CONVERT(DATE,@InDate1,120)AS CONV;