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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:19:13+00:00 2026-05-25T01:19:13+00:00

For example: Data Given : Year-2010, Month-2, Fortnight-1 Current date How do I get

  • 0

For example:
Data Given :

  1. Year-2010,
    Month-2,
    Fortnight-1

  2. Current date

How do I get the difference in terms of number of fortnights between the two given dates?


This is what I figured out and its working fine…

Calendar c= Calendar.getInstance();
int year = 2011;
int month = 6;
int fortnight = 1;
int noofmonths=(c.get(Calendar.YEAR)-year)*12;  
noofmonths=(noofmonths+((12-(month-1)+(c.get(Calendar.MONTH)-12)))-1)*2;
int nooffortnights=noofmonths+((2-(fortnight-1)+((c.get(Calendar.DAY_OF_MONTH)<15?1:2)-2)))-1;
System.out.println("nooffortnights : "+nooffortnights); //outputs 5
  • 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-25T01:19:14+00:00Added an answer on May 25, 2026 at 1:19 am

    This depends on your definition of fortnights. If we are literal minded then a fortnight is defined as 14 days, so compute the number of days and divide by 14, job done.

    I suspect that in your case we are actually using a special business calendar, where fortnights are a subdivision of quarters and hence there are some special cases – a year doesn’t exactly divide into fortnights and perhaps the business year does not start on Jan 1st? So somewhere there will be a definitive list of the dates of the start of each fortnight in a year.

    Let’s suppose that the fortnight definitions have

     17th Nov - 1st Dec
     2nd Dec - 15th Dec
     16th Dec - 31st Dec   (note this is 15 days long)
    

    Now what’s the definition on how many fortnights from 17th Nov to 16th Dec? I guess 2. From 19th Nov to 16th Dec? I have no idea what answer you would expect.

    So first, get really clear what the business requirements are. I’d be surprised is you will find off-the-shelf date packages that understand fortnights, but even if you do you need to check very carefully that they give the answers you need.

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

Sidebar

Related Questions

Is it better to use $.get(http://www.example.com/mydirectory, function(data) { $(.someclass).html(data); }); or $('.tripPlannerBottom').load(http://www.example.com/mydirectory); any speed
ex: <a><strike>example data in here</strike></a> I want everything inside the a tag, to the
I have some data with messed-up accented characters. For example in the data we
For example when editing various data files, the backup data is no use and
url = http://example.com/file.xml data = urllib2.urlopen(url) data.read() The question is, when exactly will the
For example, referencing something as System.Data.Datagrid as opposed to just Datagrid. Please provide examples
I am programmatically exporting data (using PHP 5.2) into a .csv test file. Example
How does one read a data file in an iPhone project? For example, lets
How do type casting happen without loss of data inside the compiler? For example:
Reporting services use format strings to auto format cell data. For example c2 formats

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.