difference between dates

This is a discussion on difference between dates within the C++ Programming forums, part of the General Programming Boards category; hi,i want to create 2 dates and find the number of days between them how do i create 2 dates ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    58

    difference between dates

    hi,i want to create 2 dates and find the number of days between them

    how do i create 2 dates of the dd/mm/yy format?
    then how to find the number of days between them?

    appreciate if some-one can give me a example on how to go about doing this.

    Thanking you,
    Rahul SK

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    Convert both dates to a time_t, using mktime()
    Then work out the difference (in seconds) using difftime().
    Seconds to days should be easy from there.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Difference between dates
    By DaniiChris in forum C Programming
    Replies: 11
    Last Post: 08-18-2008, 08:18 AM
  2. Getting the difference between dates
    By Leftos in forum C Programming
    Replies: 7
    Last Post: 01-19-2008, 11:49 PM
  3. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2007, 10:26 AM
  4. What's the difference between var++ and ++var
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 05-31-2007, 02:27 AM
  5. What is the Difference between ANSI C and non-ANSI C ?
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-24-2001, 05:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21