It's been a long time. Finally, I have finished the problem of the conversion of the date format, and share my little experience here, hehe
The database I use is SQL Server2005, and there is a type of smalldatetime data in the database table to store the departure time (for example: 2010-1-1 10:00:00)
Request in VC + + to extract the time and compare with the current system time, Judge size
void Csaledlg::onbtnsurebuy ()
{
Todo:add your control notification handler code here
UpdateData (TRUE);
M_editbc.trimleft ();
M_editbc.trimright ();
Cbus lt;
if (!lt. Ifexistid (M_EDITBC))
{
MessageBox ("This shift does not exist, please re-enter!");
Return
}
Get the departure time of the shift
Cbus it;
It. GetData (M_EDITBC);
CString str1 = "";
Str1+=it. GetRuntime ();
Get System Current Time
COleDateTime;
COleDateTime datetime;
Datetime=coledatetime::getcurrenttime ();
CString Str2=datetime. Format ("%y-%m-%d%h:%m:%s"); Set the system time format to match the time format in the database
Time format conversion compares CString to coledatetime,coledatetime type of time can be directly compared to size
COleDateTime T;
T.parsedatetime (STR1); Converts the CString type time in the table to COleDateTime
COleDateTime p;
P.parsedatetime (STR2); Convert the obtained system time CString type to COleDateTime
if (t<=p)//Direct judgment size
{
MessageBox ("The shift is OFF!");
Return
}
The following code is slightly 、、、、、、