How to find out the number of days in a financial year.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajukotla
    New Member
    • Jan 2008
    • 12

    How to find out the number of days in a financial year.

    How to find out the number of days in a financial year.

    suppose from date is sep1st,2006.and to date is aug24th,2009.

    the entire range involves financial years.i.e.,

    april1st,2006-march31st,2007
    april1st,2007-march31st,2008
    april1st,2008-march31st,2009
    april1st,2009-march31st,2010.
    we have to calculate the no.of days of last financial year..
    waiting for reply..
  • deepuv04
    Recognized Expert New Member
    • Nov 2007
    • 227

    #2
    Originally posted by rajukotla
    How to find out the number of days in a financial year.

    suppose from date is sep1st,2006.and to date is aug24th,2009.

    the entire range involves financial years.i.e.,

    april1st,2006-march31st,2007
    april1st,2007-march31st,2008
    april1st,2008-march31st,2009
    april1st,2009-march31st,2010.
    we have to calculate the no.of days of last financial year..
    waiting for reply..

    hi,
    you need to use a function as

    CREATE FUNCTION calcdays
    (
    @startyear int,
    @endyear int
    )
    RETURNS int
    AS
    BEGIN

    declare @count int
    set @count = 0
    while @startyear <= @endyear
    begin
    if @startyear % 4 = 0 set @count = @count + 1
    set @startyear = @startyear + 1
    end

    RETURN @count

    END
    GO

    and call the function as

    select datediff(dd, '2006-09-01','2009-08-24' ) + dbo.calcdays(ye ar('2006-09-01'),year('2009-08-24'))


    If you want number of days for each interval write a stored procedure or function to get the values


    thanks

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Originally posted by rajukotla
      How to find out the number of days in a financial year.

      suppose from date is sep1st,2006.and to date is aug24th,2009.

      the entire range involves financial years.i.e.,

      april1st,2006-march31st,2007
      april1st,2007-march31st,2008
      april1st,2008-march31st,2009
      april1st,2009-march31st,2010.
      we have to calculate the no.of days of last financial year..
      waiting for reply..
      Are you looking at finding the number of days between sep1st,2006.and to date is aug24th,2009 or something else?

      Comment

      Working...