
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
More Posts related to Linux,
- [Fix] Linux - bash: useradd: command not found
- Calculate days between dates using dateutils ddiff command
- pwd Command - Print Working Directory
- Rename a directory using Linux/Unix command
- How to go to the End of File in Nano Editor
- How to tar.gz a directory or folder Command
- How to remove/delete a directory in Linux/macOs
- How to Display content of a file in Terminal Screen?
- ls command sort by file size [Linix/UNIX/macOS/bash]
- How to Copy Entire Directory to another Directory in Linux
- 3 ways to clear screen on Linux Terminal
- Command to check Last Login or Reboot History of Users and TTYs
- How to check uptime of Linux/Unix/macOS system/server using console command?
- How to backup a file in Linux/Unix
- Command to know the installed Debian version?
- Check SSH/OpenSSH version Command
- 3 Commands to stop Nginx Server
- Linux: Create a New User and Password and Login Example
- How to install npm on Ubuntu
- How to List All Users in Linux
- How to Get the List of Shells on Linux
- Fix - ssh-copy-id no identities found error
- Installing and using unzip Command to unzip a zip file using Terminal
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- zsh hello world example
More Posts:
- The Zsh Shell - Mac Tutorial - MacOS
- DDMS files not found hprof-conv.exe - Android
- How to kill tomcat server process using Mac Terminal Command - Tomcat
- [fix] Docker: OCI runtime exec failed unable to start container process - Docker
- How to install and Configure sar sysstat tools in Ubuntu Linux - Linux
- How to use SCP Command to Copy Directory - Linux
- How to go to the End of File in Nano Editor - Linux
- How to Cut Copy and Paste in Nano Text Editor - Linux