Skip to content

How to calculate difference in days between two dates #706

Answered by san-r
san-r asked this question in Q&A
Discussion options

You must be logged in to vote

I got it

mlr --c2p --from test_date.txt ^
put "$date_diff = (strptime($date1, \"%Y-%m-%d\") - strptime($date2, \"%Y-%m-%d\"))/86400"
name date1      date2      date_diff
A    2020-09-20 2020-08-30 21
B    2020-01-31 2020-01-20 11

I wonder if there is a shorter/simpler way.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@johnkerl
Comment options

Answer selected by san-r
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@san-r
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants