Hi,
I have 2 string, "Feb 22, 2004" and "Mar 2, 2004". Is there any way to convert the string to date and get the day difference between these 2 string with visual c++??
Use COleDateTime:arseDateTime() to read the two string date into two COleDateTime objects and then do a difference.
ColeDateTime dt1 = new COleDateTime();
dt1.ParseDateTime("Feb 2, 2004",VAR_DATEVALUEONLY , LANG_USER_DEFAULT);
dt2.ParseDateTime("Mar 3, 2004",VAR_DATEVALUEONLY , LANG_USER_DEFAULT);
if (dt1.m_status == 0 && dt2.m_status == 0)
{
The two string date are valid
COleDateTimeSpan sp1 = new COleDateTimeSpan(dt1.m_dt);
COleDateTimeSpan sp2 = new COleDateTimeSpan(dt2.m_dt);
COleDateTimeSpan diff = sp1-sp2;
diff.GetDays();
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.