LoosinMaMind (9/12/2012)
HiI have been given a new system to work on and the dates are held in three seperate columns
day number ;ie 1,2,3,4 etc
month number ; ie 9,10,11 etc
year; 2011, 2012 etc
The format of these is an INT
I need to somehow concatinate the 3 into a workable date format in a SELECT statement
Any help would be greatly appreciated.
Thanks in advance
SAMPLE DATA AND EXPECTED RESULTS SCRIPT BELOW.
CREATE TABLE PS_TestForOnline
(
DAY_ INT,
MONTH_ INT,
YEAR_ INT
);
INSERT INTO PS_TestForOnline
VALUES(1,1,2012);
INSERT INTO PS_TestForOnline
VALUES(1,2,2012);
INSERT INTO PS_TestForOnline
VALUES(1,3,2012);
SELECT * FROM PS_TestForOnline
--&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
--EXPECTED RESULTS
SELECT
'1-1-2012' DATE_EXAMPLE_1, '1-2-2012' DATE_EXAMPLE_2, '1-3-2012' DATE_EXAMPLE_3 -- NEED THESE TO BE IN DATE FORMAT DD-MM-YYYY
--&&&&&&&&&&&&&&&&&&&&&&
DROP TABLE PS_TestForOnline
If you wanted to make it so you could query the table directly instead of having code do it over and over again, add a persisted computed column to the table to do the calculation that Lowel posted. Just pray people named their columns for inserts or BOOM!
--Jeff Moden
Change is inevitable... Change for the better is not.