Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to show date dd.mm.yyyy without coverting to v

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-10-19 : 05:45:14
How to show date in dd.mm.yyyy format without converting my incling datetime to varchar..
I am getting the below error.

CONVERT(varchar(10),Rev.RevisionDate,101) as RevisionDate,

[Query:Query] Cannot convert string <revisiondate> to type <datetime>, the (date/time) format of the string literal is incorrect. (BODI-1111036)

Thanks a lot for the helpful info.

NeilG
Aged Yak Warrior

530 Posts

Posted - 2012-10-19 : 05:49:12
dateformat dmy
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-10-19 : 12:30:14
Dates do not have a format, they are a number in SQL. so Showing a date in a format requires you to convert it to a string/varchar. However, if you specify the correct STYLE parameter for the convert fucntion it should work just fine:
DECLARE @RevisionDate DATETIME = SYSDATETIME();

SELECT CONVERT(varchar(10), @RevisionDate, 104) as RevisionDate

PS: Are you using SQL Server?
Go to Top of Page
   

- Advertisement -