Date and Month

  • Hello ALL,

    I have three variable,

    @fromMonth varchar(10),

    @UptoMonth varchar(10),

    @year varchar(1000)

    IF @fromMonth is null,

    I want to get result set like 12 month Differece with Year

    like

    set @Uptomonth =5

    set @year =2011,2008

    then output is

    IF @fromMonth is null,

    then

    @fromMonth =

    Month Year

    5 2011

    4 2011

    3 2011

    2 2011

    1 2011

    12 2010

    11 2010

    10 2010

    9 2010

    8 2010

    7 2010

    6 2010

    5 2008

    4 2008

    3 2008

    2 2008

    1 2008

    12 2007

    11 2007

    10 2007

    9 2007

    8 2007

    7 2007

    6 2007

    Thanks

    P

  • use datetime or date datatype whenever working with date information.

    Then you can use a simple between (for date datatype) or <= and => (for datetime)

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply