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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:39:55+00:00 2026-06-09T15:39:55+00:00

E.g. given: $quarter1 = 4; $year1 = 2011; $quarter2 = 3; $year2 = 2012;

  • 0

E.g. given:

$quarter1 = 4;
$year1 = 2011;

$quarter2 = 3;
$year2 = 2012;

I need to know that the second set are in the future compared to the first set.

I did think this could be done by literally appending the quarter onto the year. e.g.

$qy1 = 20114;
$qy2 = 20123;
// $qy1 < $qy2

But I’m sure this is not a reliable way to compare the two. Is there a better, more reliable way?

Many 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-06-09T15:39:56+00:00Added an answer on June 9, 2026 at 3:39 pm

    Nothing wrong with your method, other than having to do a few string concatenations and typecasting back to int. It could fail, however, if you fail to force the values back to integers, and you’re comparing years with different string lengths, e.g.:

    $date1 = '9994';  // year 999, q4
    $date2 = '10011'; // year 1001, q1
    

    String 9994 will compare as larger than string 10011.

    Purely as an alternative, this would work as well, keeping things purely numeric:

    $date1 = $year1 + (($quarter1 - 1) / 4);
    $date2 = $year2 + (($quarter2 - 1) / 4);
    if ($date1 < $date2) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this code snippet, I know that if the user selects 25c the value
This is for a system that essentially allows you to set the first date
Given that the web application doesn't have su privileges, I'd like to execute a
Given a certain date, I want to set the value of a cell with
Given that an input String may be specified as follows: read(xpath(‘...’)) or xpath(‘...’) or
I have an application that I know would make a great cube and would
Given this: $ids = ''; I just realized that this: $single = $ids ==
Given a tree, how to find the centre node in the tree so that
I am looking for a java library that when given from and to date
Given that the keyword using should always be used when applicable, I wanted to

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.