I am trying to create a WHERE clause that says
WHERE column_1 = TRIM(LEADING '20' FROM(DATEPART(year, GETDATE())))
Basically column_1 contains the fiscal year but the fiscal year is in the database as 8 or 9 not 2008 or 2009.
So I need to figure a way to trim off at least the '20' so that the query will run correctly… The more dynamic the better because I need to set this up to run in an SSIS pkg and the less hard coding the better.
Any suggestions? Thanks in advance! Jon
depending on the datatype of the column_1
print right(datepart(year,getdate()),2) –string with leading zero print convert(int,right(datepart(year,getdate()),2))–int
EDIT
based on @Richard’s answer
print datepart(year,getdate()) % 100