•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,614 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1386 | Replies: 4
![]() |
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,541
Reputation:
Rep Power: 40
Solved Threads: 972
convert them to doubles using SystemTimeToVariantTime() then its trivel to compare them.
•
•
Join Date: Dec 2006
Location: india
Posts: 1,085
Reputation:
Rep Power: 9
Solved Threads: 163
Dragon's suggestion of SystemTimeToVariantTime is the easiest way, but might give you inaccurate resuts if you need sub-second resolution for time. see: http://support.microsoft.com/kb/297463
if you need millisecond resolution, more work is required
if you need millisecond resolution, more work is required
cplusplus Syntax (Toggle Plain Text)
inline unsigned __int64 to_integral( const SYSTEMTIME& st ) { FILETIME ft ; SystemTimeToFileTime( &st, &ft ) ; ULARGE_INTEGER integer ; integer.LowPart = ft.dwLowDateTime ; integer.HighPart = ft.dwHighDateTime ; return integer.QuadPart ; } inline bool operator== ( const SYSTEMTIME& a, const SYSTEMTIME& b ) { return to_integral(a) == to_integral(b) ; } inline bool operator< ( const SYSTEMTIME& a, const SYSTEMTIME& b ) { return to_integral(a) < to_integral(b) ; } inline bool operator<= ( const SYSTEMTIME& a, const SYSTEMTIME& b ) { return to_integral(a) <= to_integral(b) ; } inline bool operator!= ( const SYSTEMTIME& a, const SYSTEMTIME& b ) { return !( a==b ) ; } inline bool operator> ( const SYSTEMTIME& a, const SYSTEMTIME& b ) { return !( a<=b ) ; } inline bool operator>= ( const SYSTEMTIME& a, const SYSTEMTIME& b ) { return !( a<b ) ; }
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,541
Reputation:
Rep Power: 40
Solved Threads: 972
set all the time fields in the structure to 0 then convert. Or, alternatively, you could call modf() to split the double into integer and fractional parts, then compare only the integer parts (the fractional part contains the time and integer part is the date).
Last edited by Ancient Dragon : Aug 3rd, 2007 at 7:26 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- compare (C++)
- String search in a file compare? (Computer Science and Software Design)
- Compare strings... (C++)
Other Threads in the C++ Forum
- Previous Thread: array/funtion problem, please help
- Next Thread: !!!!!!!!!!!



Linear Mode