By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,931 Members | 1,976 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,931 IT Pros & Developers. It's quick & easy.

How to enter date

P: 48
Hello everyone,
Since I am very new to programming, I am struggling with this issue. Please show me how to write current date and how to calculate duration time between today's date and previous date.

Andy
Nov 27 '06 #1
Share this Question
Share on Google+
5 Replies


bartonc
Expert 5K+
P: 6,596
Here's a tidbit to get you started:
Expand|Select|Wrap|Line Numbers
  1. # This module has lots of output formating, but date objects do print
  2. from datetime import *
  3.  
  4. dataOjb = date(MINYEAR, 1, 1)
  5. todaysDate = dataOjb.today()
  6. print todaysDate
  7.  
  8. birthDate = date(1963, 1, 28)
  9.  
  10. print todaysDate - birthDate
Nov 27 '06 #2

bartonc
Expert 5K+
P: 6,596
Hello everyone,
Since I am very new to programming, I am struggling with this issue. Please show me how to write current date and how to calculate duration time between today's date and previous date.

Andy
Hey, Andy. Since this is your first post in the Python forum, I'd like to welcome you and ask: have you given up on C++ for something just as powerfull, but a lot easier to learn? Just ask me and I'll tell you "good choice".
Nov 27 '06 #3

P: 48
Hi bartonc,
No have not, but this being my first programming course in school, i do not really have a choice. However, I am learning C++ as well. Just wasn't sure how different this language is. So far this seems easier than C++. Thanks for your help.
Nov 27 '06 #4

P: 48
however, I was looking to see if I can manually input previous date just as we write in real life.

Andy
Nov 27 '06 #5

bartonc
Expert 5K+
P: 6,596
however, I was looking to see if I can manually input previous date just as we write in real life.

Andy
This will get ints for passing to other fuctions:

Expand|Select|Wrap|Line Numbers
  1. thedate = raw_input("Enter data as mm/dd/yyyy: ")
  2. month, day, year = (int(val) for val in thedate.split('/'))
Nov 27 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.