Link to home
Start Free TrialLog in
Avatar of FMabey
FMabeyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Format date and then convert to string

I am trying to compile a string as part of a select statement in SQL which converts a date time, firstly into the desired date format (103) and then into a VARCHAR for use in the string.

The following does not work:

dbo.SHOP_RESOURCE.DESCRIPTION + '-' + dbo.LABOR_TICKET.WORKORDER_BASE_ID + '-' + CONVERT (varchar, dbo.LABOR_TICKET.OPERATION_SEQ_NO) + '-' + dbo.WORK_ORDER.PART_ID + '-' + CAST(CONVERT (DATETIME, dbo.LABOR_TICKET.TRANSACTION_DATE, 103) AS VARCHAR)

Would anyone be able to help me out on this one? I'm sure it's going to be something really easy!

Thanks

Steve
ASKER CERTIFIED SOLUTION
Avatar of OMC2000
OMC2000
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dont have to CAST as well as CONVERT

Just use CONVERT(varchar(10),dbo.LABOR_TICKET.TRANSACTION_DATE, 103)
Avatar of FMabey

ASKER

I knew it would be something simple! Thank you, was probably the only thing I hadn't tried!
Wow, that was quick - didnt even know there was another post - well done OMC2000 :)