Hi
Happy new year to you all,
I cam back after the xmas break to find that one of my date functions isnt working and im unsure why.
This is the code as it is in query Analyzer:
select (convert(char(4),year(getdate())) + '-' + cast(replace(str(Month(DATEADD(DAY,-6,getdate())),2),' ','0') as char(2)) + '-' + cast(replace(str(Day(DATEADD(DAY,-6,getdate())),2),' ','0') as char(2)))
However this returns "2006-12-29" instead of 6 days before the present date.
Can anyone help me with this.
Regards
Andy
Happy new year to you all,
I cam back after the xmas break to find that one of my date functions isnt working and im unsure why.
This is the code as it is in query Analyzer:
select (convert(char(4),year(getdate())) + '-' + cast(replace(str(Month(DATEADD(DAY,-6,getdate())),2),' ','0') as char(2)) + '-' + cast(replace(str(Day(DATEADD(DAY,-6,getdate())),2),' ','0') as char(2)))
However this returns "2006-12-29" instead of 6 days before the present date.
Can anyone help me with this.
Regards
Andy