How to check if date is between two dates in python
up vote
1
down vote
favorite
How to check if a date is between two dates in python?
EDIT1: In excel, the date that I am reading is 7/13/2018 for example.
python
add a comment |
up vote
1
down vote
favorite
How to check if a date is between two dates in python?
EDIT1: In excel, the date that I am reading is 7/13/2018 for example.
python
Give example of date format that you are using.
– Nabin
Jul 19 '17 at 4:15
Please see the update
– Mat.S
Jul 19 '17 at 4:16
Duplicate of How to tell if a date is between two other dates in Python?.
– miradulo
Jul 19 '17 at 4:20
3
Possible duplicate of How to tell if a date is between two other dates in Python?
– Jacobm001
Jul 19 '17 at 4:21
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How to check if a date is between two dates in python?
EDIT1: In excel, the date that I am reading is 7/13/2018 for example.
python
How to check if a date is between two dates in python?
EDIT1: In excel, the date that I am reading is 7/13/2018 for example.
python
python
edited Jul 19 '17 at 4:16
asked Jul 19 '17 at 4:14
Mat.S
6193824
6193824
Give example of date format that you are using.
– Nabin
Jul 19 '17 at 4:15
Please see the update
– Mat.S
Jul 19 '17 at 4:16
Duplicate of How to tell if a date is between two other dates in Python?.
– miradulo
Jul 19 '17 at 4:20
3
Possible duplicate of How to tell if a date is between two other dates in Python?
– Jacobm001
Jul 19 '17 at 4:21
add a comment |
Give example of date format that you are using.
– Nabin
Jul 19 '17 at 4:15
Please see the update
– Mat.S
Jul 19 '17 at 4:16
Duplicate of How to tell if a date is between two other dates in Python?.
– miradulo
Jul 19 '17 at 4:20
3
Possible duplicate of How to tell if a date is between two other dates in Python?
– Jacobm001
Jul 19 '17 at 4:21
Give example of date format that you are using.
– Nabin
Jul 19 '17 at 4:15
Give example of date format that you are using.
– Nabin
Jul 19 '17 at 4:15
Please see the update
– Mat.S
Jul 19 '17 at 4:16
Please see the update
– Mat.S
Jul 19 '17 at 4:16
Duplicate of How to tell if a date is between two other dates in Python?.
– miradulo
Jul 19 '17 at 4:20
Duplicate of How to tell if a date is between two other dates in Python?.
– miradulo
Jul 19 '17 at 4:20
3
3
Possible duplicate of How to tell if a date is between two other dates in Python?
– Jacobm001
Jul 19 '17 at 4:21
Possible duplicate of How to tell if a date is between two other dates in Python?
– Jacobm001
Jul 19 '17 at 4:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can convert the date so it can be easily compared in Python. Dates 1 and 2 are the converted dates, input_1 and input_2 are the two inputs from Excel. The second parameter passed in is the format in which the date is passed in.
date_1 = datetime.strptime(input_1, '%d/%m/%Y')
date_2 = datetime.strptime(input_2, '%d/%m/%Y')
date_3 = date(2017, 7, 19)
Now that you have the dates in the right format, I will check if date_3 falls within date_1 and date_2. This will return a Boolean.
date_1 < date_3 < date_2
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can convert the date so it can be easily compared in Python. Dates 1 and 2 are the converted dates, input_1 and input_2 are the two inputs from Excel. The second parameter passed in is the format in which the date is passed in.
date_1 = datetime.strptime(input_1, '%d/%m/%Y')
date_2 = datetime.strptime(input_2, '%d/%m/%Y')
date_3 = date(2017, 7, 19)
Now that you have the dates in the right format, I will check if date_3 falls within date_1 and date_2. This will return a Boolean.
date_1 < date_3 < date_2
add a comment |
up vote
1
down vote
accepted
You can convert the date so it can be easily compared in Python. Dates 1 and 2 are the converted dates, input_1 and input_2 are the two inputs from Excel. The second parameter passed in is the format in which the date is passed in.
date_1 = datetime.strptime(input_1, '%d/%m/%Y')
date_2 = datetime.strptime(input_2, '%d/%m/%Y')
date_3 = date(2017, 7, 19)
Now that you have the dates in the right format, I will check if date_3 falls within date_1 and date_2. This will return a Boolean.
date_1 < date_3 < date_2
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can convert the date so it can be easily compared in Python. Dates 1 and 2 are the converted dates, input_1 and input_2 are the two inputs from Excel. The second parameter passed in is the format in which the date is passed in.
date_1 = datetime.strptime(input_1, '%d/%m/%Y')
date_2 = datetime.strptime(input_2, '%d/%m/%Y')
date_3 = date(2017, 7, 19)
Now that you have the dates in the right format, I will check if date_3 falls within date_1 and date_2. This will return a Boolean.
date_1 < date_3 < date_2
You can convert the date so it can be easily compared in Python. Dates 1 and 2 are the converted dates, input_1 and input_2 are the two inputs from Excel. The second parameter passed in is the format in which the date is passed in.
date_1 = datetime.strptime(input_1, '%d/%m/%Y')
date_2 = datetime.strptime(input_2, '%d/%m/%Y')
date_3 = date(2017, 7, 19)
Now that you have the dates in the right format, I will check if date_3 falls within date_1 and date_2. This will return a Boolean.
date_1 < date_3 < date_2
answered Jul 19 '17 at 4:38
PeskyPotato
416415
416415
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45180858%2fhow-to-check-if-date-is-between-two-dates-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Give example of date format that you are using.
– Nabin
Jul 19 '17 at 4:15
Please see the update
– Mat.S
Jul 19 '17 at 4:16
Duplicate of How to tell if a date is between two other dates in Python?.
– miradulo
Jul 19 '17 at 4:20
3
Possible duplicate of How to tell if a date is between two other dates in Python?
– Jacobm001
Jul 19 '17 at 4:21