calculate day's between two dates

Discussion in 'C++' started by Tom, Mar 16, 2006.

  1. Tom

    Tom Guest

    Hello, please help me, I need two write a C++ program that can
    calculate the number of days between two dates.
    Tom, Mar 16, 2006
    #1
    1. Advertising

  2. Tom

    Tomás Guest

    Tom posted:

    > Hello, please help me, I need two write a C++ program that can
    > calculate the number of days between two dates.




    Step 1: Write the code

    Step 2: Get a compiler

    Step 3: Compile it


    There's bucket-loads of reusable code out there for doing this, but I
    presume you're some sort of student and you have to do it all by yourself
    so that you learn from it.


    -Tomás
    Tomás, Mar 16, 2006
    #2
    1. Advertising

  3. Tom wrote:
    > Hello, please help me, I need two write a C++ program that can
    > calculate the number of days between two dates.


    What problem did you encounter then? I suppose you did
    start on it, right?

    - J.
    Jacek Dziedzic, Mar 16, 2006
    #3
  4. Tom

    osmium Guest

    "Tom" writes:

    > Hello, please help me, I need two write a C++ program that can
    > calculate the number of days between two dates.


    Presuming this is a student exercise.....

    Top down design is usually preferred but in this case I think it would be OK
    to do bottom up. IOW, it isn't really design, it's a Topsy like growth from
    the bottom up. You can surely do that for two dates in the same month,
    right? Do that. Then consider adjacent months. where neither one of them
    is February. Then allow for intervening months in the same year. Then
    different years where neither year is a leap year. Then handle leap years
    properly. Look in a good dictionary, the leap year rule might have more
    rules than you know about.

    After completing something like this sequence you will have learned a lot
    and you can throw all that code away and write a nice pretty program that
    does what you have been asked to do.

    If this is not a student exercise, look up Julian day number.
    osmium, Mar 16, 2006
    #4
  5. Tom

    Neil Cerutti Guest

    On 2006-03-16, osmium <> wrote:
    > "Tom" writes:
    >> Hello, please help me, I need two write a C++ program that can
    >> calculate the number of days between two dates.

    >
    > Presuming this is a student exercise.....
    > <snip>
    > If this is not a student exercise, look up Julian day number.


    Or difftime.

    --
    Neil Cerutti
    Low Self-Esteem Support Group will meet Thursday at 7 to 8:30
    p.m. Please use the back door. --Church Bulletin Blooper
    Neil Cerutti, Mar 16, 2006
    #5
  6. Tom

    osmium Guest

    "Neil Cerutti" wrote:

    >> If this is not a student exercise, look up Julian day number.

    >
    > Or difftime.


    I wouldn't recommend that, it only works for a restricted set of dates. A
    baby boomer couldn't figure out how old he was in days.
    osmium, Mar 16, 2006
    #6
  7. Tom wrote:
    > Hello, please help me, I need two write a C++ program that can
    > calculate the number of days between two dates.


    pay me and I'll do it for you :)
    Diego Martins, Mar 16, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    859
    Rob Schieber
    Sep 30, 2005
  2. Alexandre Jaquet

    calculate day, hour , sec between dates

    Alexandre Jaquet, May 22, 2007, in forum: Java
    Replies:
    13
    Views:
    764
    Roedy Green
    May 28, 2007
  3. Alexandre Jaquet

    calculate day, hour , sec between dates

    Alexandre Jaquet, May 22, 2007, in forum: Java
    Replies:
    0
    Views:
    281
    Alexandre Jaquet
    May 22, 2007
  4. Alexandre Jaquet

    calculate day, hour , sec between dates

    Alexandre Jaquet, May 22, 2007, in forum: Java
    Replies:
    0
    Views:
    277
    Alexandre Jaquet
    May 22, 2007
  5. chrismo
    Replies:
    2
    Views:
    177
    Phrogz
    Jan 16, 2007
Loading...

Share This Page