asrisbey
asked on
SQL 2005 SELECT statement - simple datetime issue
This is a really simple syntax issue. I have the following select statement:
SELECT dbo.CONTENT_Event.eventID, dbo.CONTENT_Event.EventNam e + ' (' + EventOrgName + ')' + EventDate
which returns the following error:
Conversion failed when converting datetime from character string.
All I want to know is the correct syntax for returning the date only from the EventDate datetime field in dd/mm/yyyy format. By the way, I'm restricted to returning 2 columns of data, hence the select statement format.
Thanks for any help.
SELECT dbo.CONTENT_Event.eventID,
which returns the following error:
Conversion failed when converting datetime from character string.
All I want to know is the correct syntax for returning the date only from the EventDate datetime field in dd/mm/yyyy format. By the way, I'm restricted to returning 2 columns of data, hence the select statement format.
Thanks for any help.
try this
SELECT dbo.CONTENT_Event.eventID, dbo.CONTENT_Event.EventName +
' (' + EventOrgName + ')' + convert(varchar,EventDate,103)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You should use convert
example:
SELECT dbo.CONTENT_Event.eventID, dbo.CONTENT_Event.EventNam e + ' (' + EventOrgName + ')' + Convert(varchar(10), EventDate, 103)
example:
SELECT dbo.CONTENT_Event.eventID,
ASKER
I knew it would be easy! Thanks, works a treat.
SELECT dbo.CONTENT_Event.eventID,