
If you want to quickly calculate days between two dates, you can make use of the Linux dateutils ddiff command, lets see some example,
First, make sure that you have dateutils installed on your system, if not you then install it using package manager like apt-get if you are using Linux based OS or brew if using macOS
For Linux# apt-get install dateutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
dateutils
Preparing to unpack .../dateutils_0.4.5-1.1_arm64.deb ...
Unpacking dateutils (0.4.5-1.1) ...
Setting up dateutils (0.4.5-1.1) ...
For macOS
% brew install dateutils
Example: Calculate days between dates
% ddiff 2022-01-01 2022-03-01
59
% ddiff 2022-01-01 2022-01-01
0
% ddiff 2022-01-01 2022-01-02
1
% ddiff 2022-01-01 2022-01-20
19
% ddiff 2022-01-01 2022-03-01 -f '%ww %dd'
8w 3d
- How to Display content of a file in Terminal Screen?
- How to Install CVS Version Control on Linux/Ubuntu
- How to install and Configure sar sysstat tools in Ubuntu Linux
- ls command to list only directories
- [Ubuntu] Search a package and versions using apt command
- zsh hello world example
- Linux Remove or Delete Files and Directories using Terminal Commands
- How to tar.gz a directory or folder Command
- Calculate days between dates using dateutils ddiff command
- How to ls command to output one entry per line [macOS/Linux/Bash]
- 3 Commands to stop Nginx Server
- Create and write file in single Linux/macOS command
- SCP Copy all files from directory to Local Folder
- How to go to the End of File in Nano Editor
- How to remove/delete a directory in Linux/macOs
- How to Copy Entire Directory to another Directory in Linux
- Execute .bin and .run file Ubuntu Linux
- The Date Command and its usage [Linux - Unix - macOS]
- Fix - ssh-copy-id no identities found error
- How to check uptime of Linux/Unix/macOS system/server using console command?
- How to Select All text in vim/vi editor using Keyboard
- Linux: Create a New User and Password and Login Example
- Command to display epoch time Terminal
- How to install curl on Alpine Linux
- How to exit from nano command
- [fix] Java JDBC ConnectException: Connection refused - Java
- How to turn on Bluetooth on Windows 10 - Microsoft
- Android AlertDialog with Yes No and Cancel Button - Android
- Create SharePoint Site Collection using PowerShell New-SPSite - SharePoint
- How to Skip or Ignore JUnit test cases in Java - Java
- [Fix] Microsoft Teams No Network Connection Please check your network settings and try again. [2603] - Teams
- Add Calendar to SharePoint Site (Office 365) - SharePoint
- How to install iTerm2 Mac Terminal Alternative - MacOS