|
Posted by Uleric on 05/31/06 18:53
I am converting a date to a variable, then stripping out unwanted
hyphens, making sure there is a 0 in the month/day, and chomping the
year to the last 2 digits. The end result is a 6 digit integer that I
can use in my SQL.
05-31-2006 changes to 053106
Everything works except chomping the year to the last 2 digits. Substr
would normally work, but my results are ommiting the substring
completely.
BEGIN
RIGHT('00' + CAST(DATEPART(mm, @date) as varchar(2)), 2 ) +
RIGHT('00' + CAST(DATEPART(dd, @date) as varchar(2)), 2 ) +
SUBSTRING(CAST(DATEPART(yyyy, @date) as varchar(2)), -2, 2)
Any clues? Corrections?
Navigation:
[Reply to this message]
|