473,320 Members | 2,202 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,320 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 1825
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.