QDate matching not working Qt5 always getting false
Solved
General and Desktop
-
I am trying to match which date is greater than another
I am getting system date using following code
QDate systemDate = QDate::currentDate(); QString date1 = systemDate.toString("yyyy/MM/dd"); QDate systemDate1; systemDate1.fromString(date1,"yyyy/MM/dd");
and system event log date
QString xml = getStringFromEvent(publisherMetaData, nextEvents[i], EvtFormatMessageXml); //winEventList.append(eventInfo); QDomDocument dom; dom.setContent(xml); QString dateTime = dom.elementsByTagName("TimeCreated").at(0).toElement().attribute("SystemTime"); QString date = dateTime.section("T", 0, 0); QDate logDate; logDate.fromString(date,"yyyy/MM/dd");
but when i try to compare using following code i always get false even when system date < log date
if(logDate > systemDate1){ clockChanged = true; break; }
can anyone suggest some modification thank you.
-
@rkt1989 said in QDate matching not working Qt5 always getting false:
what should i do
think about why it's the case... Did you check the string?
-
@Christian-Ehrlicher ok i fixed that with
QDate logDate = QDate::fromString(date,"yyyy-MM-dd");
-
@rkt1989 Then please mark this topic as solved.