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

  • SEARCH
  • Home
  • 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 8216277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:04:19+00:00 2026-06-07T12:04:19+00:00

By using date object how we can calculate over lapping weeks? For eg: July

  • 0

By using date object how we can calculate over lapping weeks?

For eg:

July 31(Tuesday) is end for the week number 38, However week number 38 ends Sunday i.e Aug 4.

However months are different

Any idea on this

Thanks all

  • 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-06-07T12:04:22+00:00Added an answer on June 7, 2026 at 12:04 pm

    In our Calendar component, we use this code to calculate the first date in a week; and I bet it could be modified to find the last Date of the Week. IT makes use of the DateUtils library

        public static const DAY_OF_MONTH:String = "date";
    
        /**
         * This method gets the first date of the week which the given date is in.
         * 
         * @param date  This is the date for which we want to process.
         * @param firstDayOfWeek    The first day of the week, 0 (Sunday) - 6 (Saturday); 0 is the default.  It will probably be used primarily for localization purposes.
         * 
         * @return      This returns a date representing the first day of the week.
         */
        public static function firstDateOfWeek( date:Date, firstDayOfWeek : int = 0 ):Date {
            var dayIncrement : int = dayOfWeekLocalized(date, firstDayOfWeek);
    
            var returnDate : Date = DateUtils.dateAdd(DateUtils.DAY_OF_MONTH,-dayIncrement,date);
            return returnDate; 
    
        }
    
        /**
         * This method returns the position of the day in a week, with respect to the firstDayOfWeek localization variable. 
         * 
         * If firstDayOfWeek is 0; then the week is display 0 (Sunday), 1 (Monday), 2 (Tuesday), 3 (Wednesday), 4 (Thursday), 5 (Friday), 6 (Saturday).  
         * So, a Sunday would return 0, a Saturday would return 6, and so on.  
         * 
         * If firstDayOfWeek is 1; then the week is displayed as 0 (Monday), 1 (Tuesday), 2 (Wednesday), 3 (Thursday), 4 (Friday), 5 (Saturday), 6 (Sunday). 
         * However, this situation will not change the date.day value.  For display purposes we need a Sunday to return 6, a Saturday to return 5, and so on.
         * 
         * This will presumably be used for display purposes.
         * 
         * @param date  This is the date to process.
         * @param firstDayOfWeek    The first day of the week, 0 (Sunday) - 6 (Saturday); 0 is the default.  It will probably be used primarily for localization purposes.
         * 
         * @return      This returns a date representing the day’s location on the localized week display.
         */
        public static function dayOfWeekLocalized( date:Date, firstDayOfWeek : int = 0 ):int {
            var result : int = date.day - firstDayOfWeek;
            if(result < 0){
                result += 7;
            }
    
            return result;
    
        }
    

    To find the last date of a week, I suspect you can just call the firstDateOfWeek and add 6 days:

        public static function lastDateOfWeek( date:Date, firstDayOfWeek : int = 0 ):Date {
            var firstDateOfWeek : Date = firstDateOfWeek(date, firstDayOfWeek);
    
            var returnDate : Date = DateUtils.dateAdd(DateUtils.DAY_OF_MONTH,6,firstDateOfWeek );
            return returnDate; 
        }
    

    Note: The second batch of code was written in a browser and is completely untested.


    Update:
    Given a specific date, you can find out the weekOfYear number using the weekOfYear method in the DateUtils library. Use the methods above to find the first and last date of the week in question

    Conceptually like this:

    var weekOfYear : Number = DateUtils.weekOfYear(myDate);
    var firstDayOfWeek : Date = firstDateOfWeek(myDate);
    var lastDayOfWeek : Date = lastDateOfWeek(myDate);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I convert year and week to Java Date object? I'm using JodaTime,
I'm using Javascript's Date object to parse a string into a milliseconds timestamp. I'm
Basicaly I want to format a Date object using a specific pattern and the
The Java doc describe that the constructor Date(long date) constructs a Date object using
Using Python I would like to find the date object for last Wednesday. I
When initializing a new Date object in JavaScript using the below call, I found
Is there a string format of a date that a Date object can be
I'm using Java's java.util.Date class in Scala and want to compare a Date object
Is it possible to store a Date object using SharedPreferences ? Actually in my
When creating a new Date object using numbers for the parts, the value I

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.