Convert Dd/mm/yyyy To Yyyy-mm-dd In Sql Code Example


Example 1: SQL query to convert DD/MM/YYYY to YYYY-MM-DD


SELECT CONVERT(varchar(10), CONVERT(date, '13/12/2016', 103), 120)

Example 2: php convert date from dd/mm/yyyy to yyyy-mm-dd


$date = DateTime::createFromFormat('d/m/Y', "24/04/2012");
echo $date->format('Y-m-d');

Example 3: sql convert date to string yyyy-mm-dd


select CONVERT(char(10), GetDate(),126)
/* 2020-12-23 */

Example 4: sql server date format yyyy-mm-dd


convert(varchar, [column_date], 20) --(date or datetime) to yyyy-MM-dd HH:mm:ss
convert(varchar, [column_date], 23) --(date or datetime) to yyyy-MM-dd

--ref https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools