Python Forum
Convert combobox user input in to date with tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert combobox user input in to date with tkinter
#3
(Jun-29-2020, 09:22 PM)Yoriz Wrote:
from datetime import datetime

day, month, year = ('1', 'January', '2000')
mydate = datetime.strptime(f'{day} {month} {year}', '%d %B %Y')
print(mydate)
today = datetime.now()
print(today)
years = today.year - mydate.year
print(years)
Output:
2000-01-01 00:00:00 2020-06-29 22:21:04.644274 20

Thanks! That worked, but I'm only getting the date based on 2000-01-01. When I try to change the month it gives me back this error:
"Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
TypeError: update() takes 1 positional argument but 2 were given"
How can I get the all the age and the birthday that may be inserted?
Thanks again
Reply


Messages In This Thread
RE: Convert combobox user input in to date with tkinter - by Ame - Jul-01-2020, 06:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGUI] [Solved]Help storing in user input from line edit Extra 2 1,787 May-12-2022, 07:46 PM
Last Post: Extra
  [PyQt] How can I sync Combobox index to other combobox index? nickzsche 2 2,420 Jan-03-2022, 12:29 PM
Last Post: Axel_Erfurt
  Convert tkinter to pyqt razs 6 5,730 Aug-29-2021, 11:08 AM
Last Post: razs
Question [Tkinter] Can I set background color for each item in tkinter Combobox? water 1 5,166 Dec-10-2020, 07:48 PM
Last Post: Larz60+
  [Tkinter] Getting Input from Tkinter Entry juliabrushett 6 21,516 May-30-2020, 03:29 PM
Last Post: Larz60+
  Create an identification code from user input PeroPuri 1 1,929 Apr-11-2020, 11:56 AM
Last Post: Larz60+
  How can a user send a message via Contact Form in tkinter karolp 0 2,399 Apr-08-2020, 08:00 PM
Last Post: karolp
  [PyQt] Python PyQt5 - Change label text dynamically based on user Input ppel123 1 13,826 Mar-20-2020, 07:21 AM
Last Post: deanhystad
  [Tkinter] Tkinter delete combobox content and not the list LagratteCchouette 4 8,540 Dec-29-2019, 11:04 AM
Last Post: LagratteCchouette
  PyQt5: How do you set the user input of a line edit to a specific variable? YoshikageKira 17 11,867 Dec-26-2019, 03:18 PM
Last Post: Denni

Forum Jump:

User Panel Messages

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