

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to compare date strings in Python?
Python date implementations support all the comparision operators. So, if you are using the datetime module to create and handle date objects, you can simply use the <, >, <=, >=, etc. operators on the dates. This makes it very easy to compare and check dates for validations, etc.
Example
from datetime import datetime from datetime import timedelta today = datetime.today() yesterday = today - timedelta(days=1) print(today < yesterday) print(today > yesterday) print(today == yesterday)
Output
This will give the output −
False True False
- Related Questions & Answers
- Compare date strings in MySQL
- How to compare two strings using regex in Python?
- How to compare strings in Java?
- How to initialize and compare strings?
- How to compare two strings in Golang?
- Compare Strings in Arduino
- Java Program to Compare Strings
- How to Initialize and Compare Strings in C#?
- How to Initialize and Compare Strings in Java?
- How to compare two JavaScript Date Objects?
- How do I compare strings in Java?
- How to parse Date strings in Golang?
- Compare two Strings in Java
- Java Program to Compare Two Strings
- Program to Compare two strings in Java
Advertisements