[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Calculating days in 360-format from SYSTEMTIME

Posted on 2006-12-01
3
Medium Priority
?
601 Views
Last Modified: 2012-06-21
Hi, I have 2 SYSTEMTIME structures and I know how to calculate the 365-day difference between them. (FILETIME int64 etc)

My problem is to calculate the total days in a 360-day format. Excel has a function Days360 which does that, but I couldn't find something in C++.

How to do it?

Regards
0
Comment
Question by:WxW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18059093
#include <time.h>

int days360(time_t t1, time_t t2){
  struct tm tm1,tm2,*tm;
  tm1 = *localtime(&t1);
  tm2 = *localtime(&t2);
  if( tm1.tm_mday > 30 ){ tm1.tm_mday = 30; }
  if( tm2.tm_mday > 30 ){ tm2.tm_mday = 30; }
  return ((tm1.tm_year-tm2.tm_year)*12+tm1.tm_mon-tm2.tm_mon)*30+tm1.tm_mday-tm2.tm_mday;
}
0
 
LVL 6

Author Comment

by:WxW
ID: 18059110
And how to convert SYSTEMTIME to a time_t ?
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 18059139
int days360(SYSTEMTIME tm1, SYSTEMTIME tm2){
  if( tm1.wDay > 30 ){ tm1.wDay = 30; }
  if( tm2.WDay > 30 ){ tm2.wDay = 30; }
  return ((tm1.wYear-tm2.wYear)*12+tm1.wMonth-tm2.wMonth)*30+tm.wDay-tm2.wDay;
}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question