• born2achieve (10/19/2013)


    Hi Jeff Thanks for your response and great article. But i have a concern that you are using custom year next to the declaration.

    SELECT @fromYear='1913-01-01', @toYear='1998-01-01'

    I don't want this to be hard coded. because the range applied on the formula may change some point of time, The current formula

    set @start = year(getdate()) - 15

    set @Upto = year(getdate()) - 100

    Here 15, 100 may get changed in near future. so i don't want this to be card coded. is there any way to avoid this to be hard coded.

    One would expect someone to take some initiative when provided free help. The code I provided was based specifically on your orininal post, as shown here:

    born2achieve (10/18/2013)


    Hi,

    set @start = year(getdate()) - 15

    set @Upto = year(getdate()) - 100

    output has to be from 1998 ........ 1913

    i wanted to display the years between these two ranges. I am able to do using while loop. Is there any way to do this without loop. if yes please show me some sample.

    Now you are changing your specs and expecting the code provided to still work.

    Your original spec starts with the Latest year (1998) going to the earlier year (1913). If you look at the logic I employed you would see how that works. Now that you want to flip it and start at the earlier year (1913) and go to the latest year (1998) you need to adjust the logic.

    Perhaps it would be better if you told us what you are actually trying to achieve.