473,659 Members | 2,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to enter date

48 New Member
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
5 4759
bartonc
6,596 Recognized Expert Expert
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
6,596 Recognized Expert Expert
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
coolindienc
48 New Member
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
coolindienc
48 New Member
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
6,596 Recognized Expert Expert
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

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

Similar topics

1
2176
by: Dan | last post by:
Hello, I need a good way to have my users enter the date and time into a form. Could someone please give me some ideas here. What is the preferrable method for doing this in an asp form page? Should I use java script to pick the date and time? If so please tell me where I could find this. I am looking for a way to make this easy for the user. Thank you. -Dan
3
15943
by: David Kuhn | last post by:
I have a query with a date field criteria of: Between And When the query is run, I am asked for the Start date and then the End Date. So far, so good. The records returned are all those in between those dates and not records that are on the start or the end date. For example, I enter "09/01/03" for the start date and "09/30/03" for
1
1867
by: Bob Hynes | last post by:
Hi All, In access97 I have an unbound textbox with the format property set to 'short date' and an input mask of 99/99. In the after update event of the textbox I have code; me!textbox = format(me!textbox, "mm/yyyy") What I'm tring to do is let the user enter the month and two(2) digit year and then display it back to them as a four(4) digit year. This works fine up until 2001 then it screws up. examples: if I enter 11/99 it displays...
2
3279
by: buck | last post by:
I'm working on a helpdesk database - does anyone know how to auto enter the date in a new record; would it be soemthing like iif field is null auto enter?
0
1617
by: KGrein | last post by:
Hi. I have a form that contains a combo box with customer number & customer name in it. The form is called F_DeleteUSCust and the combo box is named CB_getUScust It picks up the information for Row Source from a distinct query. I have the column count as 2 and bound column 1 (saving customer number). I have 2 buttons on the form, one to preview the transactions for the save customer from the combo box and one to delete all the customers...
0
1695
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The numbers are defined as numeric in the SqlServer Database and are bound to text boxes in the app. In the dataset xml these numbers are defined as decimal. I am using the binding method Format to display the data in scientific notation and Parse to...
5
6812
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter rather than actually clicking the search button, but this does not run the search code behind the button.
0
1495
by: mlarson | last post by:
I have a program that worked fine then they needed to be able to also see the empty cells (inmate cells) on a housing unit when they ran the query. So what I had to do was take two tables and combine them into one with a query. The two tables are..inmtinfo and tblcelldata... inmtinfo IN_INNUM - primary key IN_NAME IN_RACE IN_BLDING IN_SECTION IN_CELLDRM IN_BED
3
4488
by: Bob Sanderson | last post by:
I have a PHP web page which uses a HTML form. I would like to enter dates into the date fields using a JavaScript calendar, similar to the way phpMyAdmin does. Can anyone recommend a JavaScript that will do this? Also, how can I add a button to a form to enter a NULL. Thanks in advance.
2
1284
by: tbeers | last post by:
Good afternoon. I think I could think my way through this and waste days trying to figure it out but why not use this resource. In access 2007 I have a time mangement database that basically is a timecard/data program. The techs all log there individual times through the program and it works fine. However, many of the admin types don't need to use work orders, ata codes, work codes etc, Just need to enter their time which is basically...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.