Wednesday, March 7, 2012

Change the DATETIME format to DD/MM/YYYY by using CONVERT command.

I have a database table named EMP and I have a column named
DOB(datetime) .I want to retrieve just the MM/DD/YYYY part by using
the CONVERT command.And also I need to change the MM/DD/YYYY to DD/MM/
YYYY format by using the CONVERT command by SQL query.What is the
solution ?
Thank you.
Amritendu Paul
hi Paul,
amripaul@.gmail.com wrote:
> I have a database table named EMP and I have a column named
> DOB(datetime) .I want to retrieve just the MM/DD/YYYY part by using
> the CONVERT command.And also I need to change the MM/DD/YYYY to DD/MM/
> YYYY format by using the CONVERT command by SQL query.What is the
> solution ?
> Thank you.
> Amritendu Paul
please have a look at CONVERT function in BOL:
SET NOCOUNT ON;
SELECT CONVERT(varchar(10), GETDATE(), 103) AS [my formatted date];
--<--
my formatted date
11/06/2007
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz http://italy.mvps.org
DbaMgr2k ver 0.21.0 - DbaMgr ver 0.65.0 and further SQL Tools
-- remove DMO to reply

No comments:

Post a Comment