Ïë°ÑÈÕÆÚ 2004-09-12 11:06:08.177 ת»¯³É 2004.09.12 ÕâÖÖÐÎʽ£¬¸ÃÔõô×ö£¡
Ϊʲôselect convert(VARCHAR(10),'2006-07-28',102) ÕâÖÖ²Ù×÷ûÓб仯ÄØ~£¿
SQL code:
select convert(VARCHAR(10),cast('2006-07-28' as datetime),102)
/*
----------
2006.07.28
(1 ÐÐÊÜÓ°Ïì)
*/
SQL code:
select convert(varchar(10),cast('2004-09-12 11:06:08.177' as datetime),102)
/*
----------
2004.09.12
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
*/
¿ÉÒÔÖ±½Ó°Ñ-Ìæ»»³É.
SQL code:
--ÈÕÆÚת»»²ÎÊý,ÖµµÃÊÕ²Ø
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
20040912
select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12
ÆäËüÎÒ²»³£ÓõÄÈÕÆÚ¸ñʽת»»·½·¨:
select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004
select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004
select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004
select CONVERT(varchar(12) , getdate(), 1