Hello everybody! :-) Need some help with my Win32 app - there is some SQL query to mdb file, so one of the fields is date, for example:
SqlString2 = "SELECT Main.[S/N], Employers.Employer, History.Date FROM Main INNER JOIN (Employers INNER JOIN History ON Employers.employer_code = History.employer_code) ON Main.device_code = History.device_code";
SqlString2+=" WHERE [S/N]=";
SqlString2+="'";
SqlString2+=sSerial;
SqlString2+="' ORDER BY History.Date";
recset2.Open(CRecordset::forwardOnly,SqlString2,CRecordset::readOnly);
while( !recset2.IsEOF() )
{
recset2.GetFieldValue("Date",sDate);
recset2.GetFieldValue("Employer",sEmpl);
recset2.MoveNext();
}
recset2.Close();
So the problem is - variable sDate looks like "2022-01-24 00:00:00" in this case but I need "24.01.22" - how can I format it? Thank you for advices.
CString has some formatting but not for dates that I know of.
you have 2 choices, the best one is above: extract it in the format you need instead.
the other one, in the c++, would be to shove the date into c++ date & time tools and pull it back out formatted as you need.