Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mismatch of Field types for Date on pm_project and resource_plan tables

praveenasurap
Tera Contributor

Hello All

 

We are creating a report in Platform Analytics in Yokohama and trying to compare two dates below. The type on this field is different and hence causing incorrect data matches. Is there a way to get around this issue? Please note: These Field Types are out of box and the fields are out of box from ServiceNow. 

Table: pm_project

Field: Planned End Date

Field Type: datetime

Table: resource_plan

Field: End Date

Field Type: date

 

5 REPLIES 5

M Iftikhar
Tera Sage

Hi @praveenasurap ,

A common approach is to normalize the two fields to the same type or format before comparison:

  • Strip the time component from the datetime field to get only the date part.
    This can be done via Business Rules, Script Includes, or Calculated fields.

  • Alternatively, create a new calculated field based on the datetime field that only stores the date portion.

  • Then, compare the two date-only values, which avoids mismatches caused by time differences.

In ServiceNow scripting, this is typically handled by using the GlideDateTime and GlideDate objects — converting the datetime to a date-only value by truncating the time. For example:

var plannedEndDate = new GlideDateTime(record.getValue('planned_end_date')).getDate();
var resourcePlanEndDate = new GlideDate(record.getValue('end_date'));

if (plannedEndDate.equals(resourcePlanEndDate)) {
  // dates match
}

Using getDate() on GlideDateTime extracts the date portion, and GlideDate stores the date without time — enabling accurate comparisons.

🔗 References:

 

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Thank you @M Iftikhar 

 

Is there a way to handle this without scripting and out of box functionality for Platform Analytics?

Mark Manders
Mega Patron

How are you comparing them? Is it through a DB view, or through dotwalking, or something else?

Because the other way around (from resource_plan table), I am able to select the condition 'Start date [date field]' is different Day as 'Task>Project>Planned end date [date/time field]' in the data source, and it works. In fact: using this condition as a related list condition on the pm_project table, gives the same effect.



Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Just dot walking @Mark Manders. please find below visual. we are comparing Resource_Plan end date to dot walk to Top Task and Project and to Planned End date 

 

Since they are two different types. The number of mismatches don't align. They compare beyond date.

 

praveenasurap_0-1759857542292.png