Convert 3 Date Columns into 1 Date Column
Posted on 2014-07-18
I'm pulling data from a Linked Server (DB2) and creating views. The tables in the link servers have dates in 3 fields - let's just call the 3 fields (YYYY) (MM) (DD). I don't know the data type of these fields on the DB2 side.
When I use the + in my query it adds up the 3 columns and gives me a total. The only way I have been able to accomplish getting these 3 fields into 1 field is using the following:
CONVERT(nvarchar(50),YYYY)+'-'+CONVERT(nvarchar(50),MM)+'-'+CONVERT(nvarchar(50),DD) as PO_Date
This works but I want the new "PO_Date" field to be a date field.
Any help is greatly appreciated.