Hi all,
Can you help me with this query?
In the table, they have Date_YY, Date_MM, Date_DD as 3 seperate fields. When I do the query, I want to combine these 3 fields as 1 date. So I use:
But Date_YY, Date_MM, Date_DD are float data type so instead of 20040725, I will get 2036 (2004+07+25=2036)
So I change my query to
But they both get syxtax error.
Can you help me with this query?
In the table, they have Date_YY, Date_MM, Date_DD as 3 seperate fields. When I do the query, I want to combine these 3 fields as 1 date. So I use:
Code:
Select a.field1, a.field2, ...., a.Date_YY + a.Date_MM + a.Date_DD as MyDate
from theTable a
But Date_YY, Date_MM, Date_DD are float data type so instead of 20040725, I will get 2036 (2004+07+25=2036)
So I change my query to
Code:
Select a.field1, a.field2, ...., (Cast(a.Date_YY as char(4))+ Cast(a.Date_MM as char(2)) + Cast(a.Date_DD as char(2))) as MyDate
from theTable a
OR
Select a.field1, a.field2, ...., (Convert(char(4),a.Date_YY)+ Convert(char(2),a.Date_MM) + Convert(char(2),a.Date_DD)) as MyDate
from theTable a
But they both get syxtax error.