Konversi Tanggal ke DateTime SQL
-- 2 ways
SELECT CONVERT(datetime, '2021-01-01');
SELECT CAST('2021-01-01' AS datetime);
ekkamrit
-- 2 ways
SELECT CONVERT(datetime, '2021-01-01');
SELECT CAST('2021-01-01' AS datetime);
select Cast( '2021-09-22' as date ) as castedDate;
select convert(date,'20210922') as convertedDate;
-- Create test case
DECLARE @myDateTime DATETIME
SET @myDateTime = '2008-05-03'
-- Convert string
SELECT LEFT(CONVERT(VARCHAR, @myDateTime, 120), 10)
CONVERT(DATE, datetime_expression)