Note :
STR_TO_DATE convert date in YY-MM-YY like we should be keep format same
select str_to_date('2020/10/01','%Y/%m%d')
Output : 2020-10-01
After you can change date using date_format
Example :
DATE_FORMAT
select DATE_FORMAT(STR_TO_DATE('2020/10/01','%Y/%m/%d'),'%d-%m%-%Y')
#Output : - '01-01-2020'
Example :
#STR_TO_DATE is convert to 20200101 into DATE like 2020-01-01
select STR_TO_DATE('20200101','%Y%m%d')
#Output : - '2020-01-01'
#Now you can to change DATE FORMAT in DD-MM-YY so you can use
select date_format(str_to_date('2020-09-01 00:00:00','%Y-%m-%d %k:%i:%s'),'%Y-%m-%d %k:%i:%s')
No comments:
Post a Comment