473,609 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to calculate the no. of days between two dates

1 New Member
I have two dates in an interface.One is the warranty start date and the other one warranty end date.In the next field I have warranty period which should be generated automatically by calculating the number of days between warranty start date and the warranty end date.How is this possible?
Mar 24 '14 #1
3 1835
bvdet
2,851 Recognized Expert Moderator Specialist
In Python, dates can be manipulated and date math can be performed with the time and datetime modules.
Mar 24 '14 #2
maya29988
7 New Member
Expand|Select|Wrap|Line Numbers
  1. from datetime import date
  2.  
  3. d0 = date(2008, 8, 18)
  4. d1 = date(2008, 9, 26)
  5. delta = d0 - d1
  6. print delta.days
  7.  
May 2 '14 #3
vegaseat
2 New Member
Mild improvement ...
Expand|Select|Wrap|Line Numbers
  1. from datetime import date
  2.  
  3. d0 = date(2008, 8, 18)
  4. d1 = date(2008, 9, 26)
  5. delta = abs(d0 - d1)
  6. print(delta.days)
  7.  
May 18 '14 #4

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

Similar topics

4
5364
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
1
1646
by: Guido | last post by:
How to cope with query output which provides all possible values based on a one to many relationship between two tables. I'm only interested in one answer per primary key in the 'one' table. I've tryed to filter out several values, but it does not work (because then also correct answers are lost) or still 'double' or wrong answers appear. In the many table, there are records which are not necessary for my query (or calcultions), but they...
8
2404
by: amackeyb | last post by:
I need to do a program that calculate the days from a date whatever since 20XX to January 1st. 2000. How can I do that?? I have this, is it correct??? # include <iostream.h> # include <conio.h> void main() { int month, day, year, c_year, c_month, t_days;
0
1818
by: 3skmult | last post by:
i wanna calculate the days beteween the two years ..
2
2152
by: David | last post by:
Hi, I need to display 3 fields with future dates (Fridays only) as table column headers. i.e. 16th Feb | 23rd Feb | 2nd March. As each week passes, i.e. from the Saturday, the dates should move accross 1, i.e. column 1 will update to 23rd Feb, Column 2 to 2nd March and Column 3 to 9th March.
3
2371
by: barkarlo | last post by:
how can I calculated days between e.g. 08/05/2007 and last day in that month.
9
2173
by: howzit | last post by:
I have a set date in my MySQL database that records when a Sales Lead is established and I echo that date as $row_rsLead; I need to be able to calculate how many days that lead has existed. $row_rsLead; outputs as 2007-06-14. I have made numerous attempts to create a function that will calculate the days between the lead_date and today's date, but have made absolutely no headway. I am either stuck working between differing date...
5
1904
by: Jason7899 | last post by:
hi, any one know a software to list the dates of the next changes of the daylight for example: in next 24-10-2009 the hour will change for less hour thanks for your help :)
6
4245
by: rmch | last post by:
Good Day.. Its my very first database project and I am really excited about it, trying to make for myself… I am an insurance manager and also learning access through free resources like training videos on youtube etc.. kindly help me on my problem Two Tables, tblContributionRegister & tblAgentDetails. tblContributionRegister has fields like.. Prospect_Name (text), Proposal_No (text), Policy_No (text), Submission_Date (Date/time), Issued_Date...
1
1217
by: CostasM | last post by:
I need to get difference between two dates with time in days using usual query. See picture for details :https://dl.dropbox.com/u/37289693/DaysHoursDif.jpg
0
8109
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
8035
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
8534
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
8509
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...
1
8188
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8374
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6969
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
4002
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
4059
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.