Jun-24-2024, 02:28 PM
im making a reminder app. one of the first step would be to only accept dates set in the future and not in the past to avoid any user mistakes. Does anyone know how to do this? much appreciated
reminder app logic problem
|
Jun-24-2024, 02:28 PM
im making a reminder app. one of the first step would be to only accept dates set in the future and not in the past to avoid any user mistakes. Does anyone know how to do this? much appreciated
Here is one way.
from datetime import datetime present = datetime.now() past_date = '2015-10-25' obj = datetime.strptime(past_date, '%Y-%m-%d') answer = 'yes' if obj < present else 'no' print(f'Past -> {answer}') future_date = '2025-12-23' obj = datetime.strptime(future_date, '%Y-%m-%d') answer = 'yes' if obj < present else 'no' print(f'Future -> {answer}')Came from here
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags
Jun-24-2024, 03:50 PM
thanks a lot for your help mate.. much appreciated
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Problem in formulating append logic | shantanu97 | 1 | 1,125 |
Jun-07-2022, 08:35 AM Last Post: ibreeden |
|
Python Reminder MSTeams Chatbot | ajaymedidi | 0 | 1,226 |
Sep-16-2021, 07:13 AM Last Post: ajaymedidi |
|
Problem with and if() logic | nikos | 2 | 2,122 |
Feb-11-2019, 10:14 PM Last Post: nikos |
|
Number logic problem | m1xzg | 13 | 11,041 |
Oct-23-2016, 09:36 PM Last Post: m1xzg |