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 Download my project scripts
Jun-24-2024, 03:50 PM
thanks a lot for your help mate.. much appreciated
Jul-01-2024, 10:30 PM
Hey, that sounds like an excellent idea for a reminder app! To ensure users can only set future dates, you can compare the selected date with the current date and time. You can show an error message if the selected date is earlier than the current date. In Python, you could use the datetime module to do this.
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Problem in formulating append logic | shantanu97 | 1 | 1,846 |
Jun-07-2022, 08:35 AM Last Post: ibreeden |
|
Python Reminder MSTeams Chatbot | ajaymedidi | 0 | 1,647 |
Sep-16-2021, 07:13 AM Last Post: ajaymedidi |
|
Problem with and if() logic | nikos | 2 | 2,844 |
Feb-11-2019, 10:14 PM Last Post: nikos |
|
Number logic problem | m1xzg | 13 | 13,816 |
Oct-23-2016, 09:36 PM Last Post: m1xzg |