Search code examples
cmfcansi-c

display date 90 days earlier form CURRENT (ANSI C)


Is there an easy way to calculate 90 days earlier than current? For example if it is 31 of May today, what is the date 90 days earlier? Is there a function to do so? Thanks


Solution

  • The COleDateTime (link) and COleDateTimeSpan (link) classes could be used.

    #include <atlcomtime.h>
    
    COleDateTime dt = COleDateTime::GetCurrentTime();
    COleDateTimeSpan span(90, 0, 0, 0);
    COleDateTime dt2 = dt - span;