Monday, March 19, 2012

Date in Europe format.

In my table in SQL Server my date column is the data type of datetime. One of the row is 2003-06-17 00:00:00.000. I have to display in my reports the date as 17/06/2003. What will be the syntax I will need to use?
Select (datepart(day,ReturnByDt) + '/ ' + datepart(month,ReturnByDt)+ '/'+ datepart(year,ReturnByDt)) from tblA

I get an error message:
Syntax error converting the varchar value '/ ' to a column of data type int.

Any ideas??
Thanks
SriDates are stored in the database as numbers...you need to pick your format.

Look up convert

oh, and here

SELECT CONVERT(varchar(10),Getdate(),103)|||Select cast(datepart(day,@.ReturnByDt) as varchar(5)) + '/' + cast(datepart(month,@.ReturnByDt) as varchar(5))+ '/'+ cast(datepart(year,@.ReturnByDt) as varchar(5))

Originally posted by sri2003
In my table in SQL Server my date column is the data type of datetime. One of the row is 2003-06-17 00:00:00.000. I have to display in my reports the date as 17/06/2003. What will be the syntax I will need to use?
Select (datepart(day,ReturnByDt) + '/ ' + datepart(month,ReturnByDt)+ '/'+ datepart(year,ReturnByDt)) from tblA

I get an error message:
Syntax error converting the varchar value '/ ' to a column of data type int.

Any ideas??
Thanks
Sri|||Brett's idea is better. Ignore mine.|||Brett..Thanks a million for your quick reply.

Originally posted by Brett Kaiser
Dates are stored in the database as numbers...you need to pick your format.

Look up convert

oh, and here

SELECT CONVERT(varchar(10),Getdate(),103)|||Sorry was not clear....Your syntax worked perfect for me.
Originally posted by sri2003
Brett..Thanks a million for your quick reply.

No comments:

Post a Comment