data para string sql
SELECT
TO_CHAR(SYSDATE, 'YYYY-MM-DD')
FROM
dual;
Code language: SQL (Structured Query Language) (sql)
Meidiana Rahmawati
SELECT
TO_CHAR(SYSDATE, 'YYYY-MM-DD')
FROM
dual;
Code language: SQL (Structured Query Language) (sql)
DECLARE @dt DATETIME = '2019-12-31 14:43:35.863';
SELECT
CONVERT(VARCHAR(20),@dt,0) s1,
CONVERT(VARCHAR(20),@dt,100) s2;
=========================================
OUTPUT
=========================================
s1 s2
-------------------- --------------------
Dec 31 2019 2:43PM Dec 31 2019 2:43PM
(1 row affected)