I ahve SYSTEMTIME sysTimeA and sysTimeB

I want to know the difference in number of days.
Ex. If sysTimeA was 20 days befor sysTimeB,
then sysTimeA-sysTimeB = 20 days.

I want their difference in days. Not as: 2 week and 6 days (which I can get from SYSTEMTIME structure)
Is there any API or a way to do so?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hi pb_india,

hmmmm ... what about:   days_diff = weeks * 7 + days ???

pb_indiaAuthor Commented:
Nope. ABout week, that was just one example I gave. SystemTime gives in year, month, etc too. I wanted to know if there was any better API that does it already.,
In MFC, it provides CTime(), that takes Systemtime as parameter .

int days = CTime(sysTimeA,0)-CTime(sysTimeB,0) ;

I am looking for something like this but without MFC
Hi pb_india,

Use SystemTimeToFileTime to convert it.

I quote:

'The FILETIME structure holds an unsigned 64-bit date and time value for a file. This value represents the number of 100-nanosecond units since the beginning of January 1, 1601.'

A little simple maths should get you what you want from there.

pb_indiaAuthor Commented:
Can you please show me the math to convert it to days?
My documentation suggests copying the FILETIME to a ULARGE_INTEGER and then working with that.

To get days from 100ns units (I think) you will need:

1ns = 1/1,000,000,000seconds so 100ns = 1/10,000,000seconds
to get minutes, divide again by 60
to get hours, divide again by 60
to get days divide again by 24 so

days = <time in 100ns>/10,000,000/60/60/24 or <time in 100ns>/864,000,000,000


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.