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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:09:11+00:00 2026-06-14T03:09:11+00:00

So for example if I have the following code: var nodaStart = new LocalDate(2012,

  • 0

So for example if I have the following code:

var nodaStart = new LocalDate(2012, 5, 1);
var nodaEnd = new LocalDate(2012,5,2);
var daysBetween = Period.Between(nodaStart, nodaEnd,PeriodUnits.Day);

Then daysBetween.Days == 1

However, the range I calculate needs to count that as 2 days. i.e. it needs to be inclusive of the start and end date.

The actual method can take and start and end date (that are no more than a year apart) and needs to calculate the number of days. If there are more than 31 days then the remainder are returned as a number of whole weeks.

I have that logic working fine but because the count is exclusive I’m one day out.

I guess I can just do startDate.addDays(-1) before I create nodaStart from it but I wonder if there’s a more elegant / pretty way to have noda return the Period.

Thanks


UPDATE:
I’ve had a read of the source code for the Period class and the + operator is overloaded so I can add

daysBetween += Period.FromDays(1);
  • 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-14T03:09:12+00:00Added an answer on June 14, 2026 at 3:09 am

    (Sorry it’s taken me so long to answer this – I hadn’t seen it before.)

    Any of:

    • Adding a day to the end before calculating (this is the most logical approach, IMO – as Roger says, you want the start of the next day, effectively)
    • Subtracting a day from the start before calculating
    • Adding 1 to the number of days you get out of the end

    should be fine. I don’t think Noda Time will change to make this any simpler. Between is a sort of “fuzzy around units” version of a subtraction operator – and you won’t find many subtraction operators where 2 – 1 is 2.

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

Sidebar

Related Questions

I have the following example code: $dataProvider = new CActiveDataProvider('firstTable', array('criteria' => array( 'select'
I have the following code: var commitmentItems = new List<CommitmentItem<ITransaction>>(); commitmentItems.Add(new CapitalCallCommitmentItem()); And I
For example I have following jQuery code: var div1 = $(divs).next(); How do I
I have the following example code var object = { userDefinedFunction : function(){ //no
in socket.io 0.6, i have following example code: var io = require('/usr/lib/node_modules/socket.io'); var server
i have following code example: PlentySoapRequest_GetAuthentificationToken username = new PlentySoapRequest_GetAuthentificationToken(); username.Username = user_textbox.ToString(); username.Userpass
I have the following code: [..] var img = document.createElement('img'); img.src = 'www.example.com/pixeltracking'; [..
I have the following code var container = new UnityContainer(); //LINE 1 container.RegisterType<ILogUtility,LogUtil>(); //LINE
Say I have the following code: <div onclick='location.href=http://www.example.com/'> <a href='#' onclick='alert(blah)'>click</a> </div> Is there
On a report I have the following code for a field: =Sum([PartQty]*[ModuleQty]) Example results

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.