changing the date into a number

This is a discussion on changing the date into a number within the C++ Programming forums, part of the General Programming Boards category; ok so i read the function help on this site and found out how to get the date now all ...

  1. #1
    bleeeeeeeeeh
    Guest

    changing the date into a number

    ok so i read the function help on this site and found out how to get the date now all i want is to be able to compare the date to another varible so i would like to be able to change the date into a number...

  2. #2
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    read each part of the date into an int
    so you have

    d=21
    m=01
    y=2001

    then cast them to strings and join them up tom become one string
    dmy [8] ="21012001"
    Monday - what a way to spend a seventh of your life

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    If you're comparing dates against other dates, it is probably easier to reverse them -

    yyyymmdd

    20020121

    That way you can tell with one comparison if one date is before or after another.

  4. #4
    Unregistered
    Guest
    ok so now how do i change hold_time into this format yyyymmdd

    Code:
    #include <time.h>
    #include <iostream.h>
    
    int main()
    {
    	time_t hold_time;
    	hold_time=time(NULL);
    	cout<<hold_time;
    	cout<<time;
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-20-2009, 11:37 PM
  2. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 05:55 PM
  3. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  4. Perfect number...
    By Argo_Jeude in forum C++ Programming
    Replies: 8
    Last Post: 07-12-2005, 01:53 PM
  5. Assingnment problem
    By Jason in forum C Programming
    Replies: 1
    Last Post: 08-31-2001, 01:20 PM

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