Date difference different results in Excel vs Python

0 votes

I have a pandas data frame with two dates columns with timestamps ( i want to keep a timestamp) I want to get the difference in days between those two dates, I used the below. It works just fine.

mergethetwo['diff_days']=(mergethetwo['todaydate']-mergethetwo['LastLogon']).dt.days

The doubt is, when I got the difference between those two dates in Excel, it gave me different numbers.

In python for example the difference between

5/15/2020 1:48:00 PM (LastLogon) and 6/21/2020 12:00:00 AM(today date) is 36 .

However, in Excel using

DATEDIF =(LastLogon,todaydate,"d") 5/15/2020 1:48:00 PM and 6/21/2020 12:00:00 AM is 37 days !

Why is the difference? Which one should I trust? As I have 30,000 + rows, I can't confirm all of them.

Appreciate your support Thank you

Feb 22, 2022 in Database by Edureka
• 13,690 points
1,150 views

1 answer to this question.

0 votes

To calculate the date difference, we can use the function  DATEDIF() 
The syntax for the same is =DATEDIF(Start_Date, End_Date, Metric)
where, start date is the first date u want to calculate from
and end date is the last date 
Metric is 

  • “d”: Days
  • “m”: Months
  • “y”: Years
    It’s important to note that this function won’t automatically appear in Excel until you completely type =DATEDIF
answered Feb 23, 2022 by gaurav
• 23,260 points

Related Questions In Database

0 votes
0 answers

Modify an existing Excel file using Openpyxl in Python

I am basically trying to copy some ...READ MORE

Mar 25, 2022 in Database by Edureka
• 13,690 points
2,086 views
0 votes
1 answer

Reading an Excel file in python using pandas

How to Use Pandas to Import an ...READ MORE

answered Mar 30, 2022 in Database by gaurav
• 23,260 points
2,733 views
0 votes
1 answer

Convert Date to Text without losing the format in Excel?

The steps are as follows: Copy the dates ...READ MORE

answered Apr 1, 2022 in Database by gaurav
• 23,260 points
39,992 views
0 votes
1 answer

Connection vs Query in Excel data model

There are various ways to construct and ...READ MORE

answered Apr 4, 2022 in Database by Edureka
• 13,690 points
2,314 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,467 views
0 votes
1 answer
0 votes
1 answer

Hours and minutes difference between two times in Excel

Using the TEXT function in Excel is ...READ MORE

answered Mar 25, 2022 in Database by gaurav
• 23,260 points
1,187 views
0 votes
1 answer

Remove time from date field in Excel formula

Use the Find And Replace function to ...READ MORE

answered Mar 30, 2022 in Database by gaurav
• 23,260 points
950 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP