GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - markwhitaker/MonthDiff: Simple C# extension methods to calculate the difference in months between two dates

This repository was archived by the owner on Jun 27, 2026. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

57 Commits
57 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
MonthDiff.Lib
MonthDiff.Lib
 
 
MonthDiff.Tests
MonthDiff.Tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
MonthDiff.sln
MonthDiff.sln
 
 
README.md
README.md
 
 

Repository files navigation

MonthDiff

A very simple pair of extension methods on DateTime and DateTimeOffset to calculate the difference in months between two dates.

I wanted it to work exactly like a TotalMonths property on TimeSpan would work, i.e. return the count of complete months between two dates, ignoring any partial months. Because it's based on DateTime.AddMonths() it respects different month lengths and returns what a human would understand as a period of months. Unfortunately it can't be implemented as an extension method on TimeSpan because that doesn't retain knowledge of the actual dates used, and for months they're important.

Originally posted at StackOverflow.

About

Simple C# extension methods to calculate the difference in months between two dates

Topics

c-sharpdatetimedatetimeoffsetextension-methodsmonths

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

1 fork
Report repository

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.