Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6569461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:37:47+00:00 2026-05-25T14:37:47+00:00

How can I get how many Sundays there are between now and the end

  • 0

How can I get how many Sundays there are between now and the end of the month? I’m not really experienced with JS date objects, so I don’t know where to start. I could loop through the days between now and the end of the month and check if the day is Sunday, but that would be only a worst-case solution.

Anyone got any idea about this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:37:47+00:00Added an answer on May 25, 2026 at 2:37 pm

    If it’s only from now and end of the month, the worst case if only O(31) which is VERY MUCH you can say it’s as fast as O(1). The small optimization could be done by finding the first sunday then add 7 a couple of times until it passes or equals to 28, count that “couple of times” + 1 (for the first sunday) and you get the number of sundays. The worst case is now around O(10), O(7) for finding the first sunday, O(3) for the loop. But really, do you want to do this?

    NOTE: maybe I miscount the complexity a little, but it’s around those numbers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The page of OpenERP web client can get really wide with many columns in
Is there any way I can get how many player has played my game
On many Android devices you can get into a secret settings menu from Phone
We can get class Class object by 3 methods: MyClass.class obj.getClass Class.forName(className) I don't
Is there anyway I can get the request details when there's an ajax error.
Is there any site from where I can get the most of the information
How can I get how many times a string occurs in a textbox? I
I can get diffs between two revisions using something like svn diff -r 100:200
Is there a way so that I can get access to request object, while
How can you get many tags for a question effectively from Postgres database by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.