473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to calculate the no. of days between two dates

1
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 1828
bvdet
2,851 Expert Mod 2GB
In Python, dates can be manipulated and date math can be performed with the time and datetime modules.
Mar 24 '14 #2
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
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
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...
1
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...
8
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...
0
by: 3skmult | last post by:
i wanna calculate the days beteween the two years ..
2
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...
3
by: barkarlo | last post by:
how can I calculated days between e.g. 08/05/2007 and last day in that month.
9
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....
5
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
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...
1
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.