• smharabbani40 (10/11/2013)


    Hi

    MonthYear is the INT data type.that is only the issue ,becuse of that between is not working....i can able to change datatype....

    if any suggestion/fixe rather than this please let me know.

    Thanks in advanced.............:-)

    Yeah the between is likely going to return values you don't want. Consider 122012. That would be december 2012 according to your pattern. It in fact does belong between 112013 and 122013 but it is not what you want in your query. This type of datemath is exactly what I was referring to in my first post. I would probably change this to a date datatype and then you can this type of query quite easily.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/