Date Intervals like YTD

  • My requirement is,we have a drop down in our application with YTD,QTD,MTD

    YTD--Year To Till Date.

    QTD--Quarterly To Till Date.

    MTD--Monthly To Till Date.

    Please suggest me a query for retrieving values for the selected item from dropdown.

  • maddhi.srikanthreddy (4/15/2013)


    My requirement is,we have a drop down in our application with YTD,QTD,MTD

    YTD--Year To Till Date.

    QTD--Quarterly To Till Date.

    MTD--Monthly To Till Date.

    Please suggest me a query for retrieving values for the selected item from dropdown.

    an idea to get you started

    select (DATEADD(year, -1, getdate()))

    some good reading here from a well respected forum member:

    http://www.sqlservercentral.com/blogs/lynnpettis/2009/03/25/some-common-date-routines/

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • I'm not exactly sure what you are looking for here. Are you trying to display aggregate values for YTD/QTD/MTD side by side, are you attempting to return separate result sets based on reporting YTD or QTD or MTD values?

  • If you are dealing with accounting periods that don't map to the calendar, I don't know of any good way to do this other than constructing a calendar table with the values for MTD, YTD, and QTD for each date, or some similar structure with start and end dates for each type of period enumerated. Are you using calendar months and quarters or accounting months and quarters?


    And then again, I might be wrong ...
    David Webb

  • It also depends if the Fiscal Months/quarters/year will map to actual months/quarters/year. Most of the companies I have worked for the fiscal year/quarters/months may not have been the calendar year/quarters/months but were easily mapped to them using an offset. Those companies that use 4-4-5 or similar months/quarters, yes, a calendar table is almost certainly a must.

Viewing 5 posts - 1 through 4 (of 4 total)

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