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 in Database by Edureka
• 9,320 points
42 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 by Edureka
• 8,820 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 in Database by Edureka
• 9,320 points
32 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 in Database by Edureka
• 8,820 points
42 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 in Database by Edureka
• 8,820 points
46 views
0 votes
1 answer

Connection vs Query in Excel data model

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

answered Apr 4 in Database by Edureka
• 9,320 points
32 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 2,756 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 in Database by Edureka
• 8,820 points
22 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 in Database by Edureka
• 8,820 points
19 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP