Complex Query
- From: "Uleric" <Uleric@xxxxxxxxx>
- Date: 31 May 2006 11:53:29 -0700
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?
.
- Follow-Ups:
- Re: Complex Query
- From: David Portas
- Re: Complex Query
- Prev by Date: Re: Question on Transaction Log Backups
- Next by Date: Re: Complex Query
- Previous by thread: Linked Server Time Difference
- Next by thread: Re: Complex Query
- Index(es):
Relevant Pages
|