Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reminder app logic problem
#1
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
Reply
#2
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


Reply
#3
thanks a lot for your help mate.. much appreciated
Reply


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,121 Feb-11-2019, 10:14 PM
Last Post: nikos
  Number logic problem m1xzg 13 11,024 Oct-23-2016, 09:36 PM
Last Post: m1xzg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020