Thread: difference between dates

  1. #1
    Registered User
    Join Date
    Feb 2006

    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    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.

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-20-2008, 12:49 AM
  3. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of
    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, 06:55 AM