Compare times
-
Hi, I need to compare times which are strings. There is a structure for time. I don't have idea about that. Can u help out to compare times which are strings. Thanks
-
Hi, I need to compare times which are strings. There is a structure for time. I don't have idea about that. Can u help out to compare times which are strings. Thanks
You can: (1) Parse the strings and compare the respective integer values obtained. (2) Transform your string data (maybe via parsing again) to an opportune object (such a
CTime
instance if you're using MFC) and then using related members to perform comparison. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
You can: (1) Parse the strings and compare the respective integer values obtained. (2) Transform your string data (maybe via parsing again) to an opportune object (such a
CTime
instance if you're using MFC) and then using related members to perform comparison. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
Hi, I found one function strptime which converts string to time.I have included time.h and string.h header files . Even then i am getting the error 'strptime identifier not found;
-
Hi, I found one function strptime which converts string to time.I have included time.h and string.h header files . Even then i am getting the error 'strptime identifier not found;
sireesha_sree wrote:
I found one function strptime...
Where? It does not appear to be part of MSVCRT.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hi, I found one function strptime which converts string to time.I have included time.h and string.h header files . Even then i am getting the error 'strptime identifier not found;
sireesha_sree wrote:
i am getting the error 'strptime identifier not found
Because it isn't. Have a look at here [^]]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Hi, I need to compare times which are strings. There is a structure for time. I don't have idea about that. Can u help out to compare times which are strings. Thanks
If you are in VC++, you can get the strings for the time like that: CTime time = CTime::GetCurrentTime(); CString szTime = time.Format ( "%A, %d.%B.%Y, %H:%M:%S" ); The CTime is a class and have methodes like: GetTime Returns a time_t that corresponds to this CTime object. GetYear Returns the year that this CTime object represents. GetMonth Returns the month that this CTime object represents (1 through 12). GetDay Returns the day that this CTime object represents (1 through 31). GetHour Returns the hour that this CTime object represents (0 through 23). GetMinute Returns the minute that this CTime object represents (0 through 59). GetSecond Returns the second that this CTime object represents (0 through 61). GetDayOfWeek Returns the day of the week (1 for Sunday, 2 for Monday, and so forth). If you are in c++ then use the struct time_t (in < time.h >) and isollate every member of the struct to compare them.
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?