Discussions

Expand all | Collapse all

How to find no of Sundays in a Month

  • 1.  How to find no of Sundays in a Month

    Posted 21 days ago
    Hi,
    I want to find the count of how many Sundays are there in a month basis on which i would like to find out No of Days in a month - No of Sundays.

    I have created a daily data entry form in which the user will enter the date. I would like to find out how many sundays will occur in that given month for which the date is entered.

    For Example if the user enters the date as 15.03.2020 then March 2020 has 31 days and 5 Sundays so 31-5=26 should be my end result.

    Is there a way thru which the same can be achieved?

    Regards
    Gunsham

    ------------------------------
    Gunsham Lakhiani
    ------------------------------


  • 2.  RE: How to find no of Sundays in a Month

    Posted 8 days ago
    Hi, I think I have a solution in the screenshot below. The formulas are to the right of the fields

    Enter any date in field Date2
    calculated date field bom-date2= FirstDayOfMonth([Date2])
    Day of week-bomdate2 =DayOfWeek([bom-date2])
    eom-date2 = LastDayOfMonth([Date2])
    days in date2 month=ToDays([eom-date2]-[bom-date2])+1
    first sunday of month= Case([Day of week-bom-date2],0,[bom-date2],
    1,[bom-date2]+Days(6),
    2,[bom-date2]+Days(5),
    3,[bom-date2]+Days(4),
    4,[bom-date2]+Days(3),
    5,[bom-date2]+Days(2),
    6,[bom-date2]+Days(1)
    )
    Sundays =Ceil(ToDays([eom-date2]-[first sunday of month])/7)
    Days in month - no Sundays = [days in date2 month]-[Sundays]


    ------------------------------
    Lisa Sell
    ------------------------------



  • 3.  RE: How to find no of Sundays in a Month

    Posted 8 days ago
    I had this formula in my bag of tricks. This one is for Fridays.  I'm pretty sure that if you change the Days(5) to be Days (0), it will count Sundays.  ie what goes in the brackets is the Day # of the week starting at Sunday = 0.


    var date MyDate = [In Coming Date];
    var date MonthStart = FirstDayOfMonth($MyDate);

    If(FirstDayOfMonth(FirstDayOfWeek($MonthStart) + Days(5) - Days(7)) = $MonthStart,1,0)
    +
    If(FirstDayOfMonth(FirstDayOfWeek($MonthStart) + Days(5) + Days(0)) = $MonthStart,1,0)
    +
    If(FirstDayOfMonth(FirstDayOfWeek($MonthStart) + Days(5) + Days(7)) = $MonthStart,1,0)
    +
    If(FirstDayOfMonth(FirstDayOfWeek($MonthStart) + Days(5) + Days(14)) = $MonthStart,1,0)
    +
    If(FirstDayOfMonth(FirstDayOfWeek($MonthStart) + Days(5) + Days(21)) = $MonthStart,1,0)
    +
    If(FirstDayOfMonth(FirstDayOfWeek($MonthStart) + Days(5) + Days(28)) = $MonthStart,1,0)


    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------