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 694279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:50:25+00:00 2026-05-14T02:50:25+00:00

I have a interesting question: I want to split the year into 4 quarters.

  • 0

I have a interesting question:

I want to split the year into 4 quarters. What is the idea,

A quarter can be different:

The HTML Code:

<div class="quarterBody">
    <span>04-29-2010</span>
    <span>06-29-2010</span>
    <span>08-29-2010</span>
</div>

jQuery (javascript) is total wrong, I hope that w:

       $(document).ready(function(){

            var quarter1 = to make interval (01-01-2010  to 03-31-2010);
            var quarter2 = to make interval (03-01-2010  to 06-31-2010);
            var quarter3 = to make interval (06-01-2010  to 09-31-2010);
            var quarter4 = to make interval (09-01-2010  to 12-31-2010);
                              ...

            $(".quarterBody span").each(function(){
                var date = Date.parse($(this).text());

                //to apply some magic code 

                $(this).addClass(quarterNumber);

            });
        });

OUTPUT:

<div class="quarterBody">
        <span class="Quarter1">02-29-2010</span>
        <span class="Quarter2">04-29-2010</span>
        <span class="Quarter3">08-29-2010</span>
             ...
    </div>

I know right now it is a stupid way, but I hope that somebody can help me, or suggest an idea how to do that in a better way!!

Thanks!

  • 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-14T02:50:26+00:00Added an answer on May 14, 2026 at 2:50 am

    Instead of specifying an interval, you can simply get the month and calculate the quarter from that:

    $(function(){
      $('.quarterBody span').each(function() {
        var month = parseInt($(this).text().substr(0,2), 10);
        var quarter = Math.floor((month - 1) / 3) + 1;
        $(this).attr('class', 'Quarter' + quarter);
      });
    });
    

    Notice:

    • I corrected the spelling on “quarterBody” and “Quarter1” through “Quarter4”.
    • This assumes the date format that you showed, with the first two digits always being the month.
    • When parsing the string containing the month, you have to specify the base (10), otherwise months ’01’ to ’09’ will be parsed as octal (base 8), and ’08’ and ’09’ are not valid octal numbers.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's an interesting question :) I have two vectors of matrices which I want
I have an interesting project in mind, and I have a question. You can
I have an interesting question about interface builder and ARC. I am building a
An interesting question arose today. Let's say I have a .NET object that implements
I have recently come across an interesting question on strings. Suppose you are given
Here's an interesting question about the various quirks of the C++ language. I have
So I have an interesting design question regarding an app I'm developing for the
I have an interesting question. Imagine I have a lot of data changing in
I have a very interesting LINQ question. I have a document, that I am
I want to put a question about what ideas do you have regarding Open

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.