相关文章推荐
严肃的黄瓜  ·  c# winform TreeView ...·  3 月前    · 
怕老婆的四季豆  ·  "CASE" statement ...·  1 年前    · 

I want to calculate the difference between the two dates but want to exclude the weekends from it . Below is the format of dates :

CreateDate - 2017-08-29 10:47:00

ResolveDate - 2017-09-23 16:56:00

解决方案from datetime import datetime

import numpy as np

create_date = "2017-08-29 10:47:00"

resolve_date = "2017-09-23 16:56:00"

create_datetime = datetime.strptime(create_date, '%Y-%m-%d %H:%M:%S')

resolve_datetime = datetime.strptime(resolve_date, '%Y-%m-%d %H:%M:%S')

print(f"The difference in days is: {(resolve_datetime - create_datetime).days}")

print(f"The difference in business days is: {np.busday_count(create_datetime.date(), resolve_datetime.date())}")

Output:

The difference in days is: 25

The difference in business days is: 19

I want to calculate the difference between the two dates but want to exclude the weekends from it . Below is the format of dates :CreateDate - 2017-08-29 10:47:00ResolveDate - 2017-09-23 16:56:00解决方案...