Search This Blog

Wednesday, September 23, 2009

Finding current , previous and next date/time using COleDateTime



COleDateTime currdate;
COleDateTime prevdate;
COleDateTime nextday;
currdate = COleDateTime::GetCurrentTime();
CString csTime= currdate.Format(); //current date and time

COleDateTimeSpan span(1,0,0,0);

int nDay = currdate.GetDay(); //current day

prevdate = currdate - span;
nextday = currdate + span;

int nPrevDay = prevdate.GetDay(); //yesterday or Previous day

int nNextDay = nextday.GetDay(); //next day

No comments: