CAST ( expression AS data_type [ (length ) ])Example:
Syntax for CONVERT:
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
Format Date to mm/dd/yyyy
CONVERT(nvarchar(11),[FieldName],101)
From: '2007-05-04 16:35:52.140'
To: '05/04/2007'
Reseting Time Value to Zero
CAST(CONVERT(nvarchar(11),[FieldName],101) as datetime)
From: '2007-05-04 16:35:52.140'
To: '2007-05-04 00:00:00.000'
No comments:
Post a Comment