+ Start a Discussion
Maggie LongshoreMaggie Longshore 

Why does last modified date return as Reports.ColumnDataType.DATE_DATA in report?

I am working on custom code to process data in a report. When I have the last modified date field on the account in the report the column data type returned for the field is DATE_DATA and not DATETIME_DATA.

Is there a reason it is not DATETIME_DATA? the time portion is in the value such as 2017-08-15 14:26:08

I realize the time portion does not display when viewing the report through the Salesforce UI.  
Best Answer chosen by Maggie Longshore
Alain CabonAlain Cabon
Hi,

Show LAST MODIFIED "TIME" on reports

Salesforce allows us to show the Last Modified DATE on reports, but does not yet allow us to show the Last Modified TIME. Being able to report the TIME that something was modified would be very helpful.

Comment: And still not delivered after 9 years?

https://success.salesforce.com/apex/ideaView?id=08730000000Bre3AAC

Displaying both - date and time of Last Modified Date or Created Date of activity in a report​

The reports can show last modified date or created date of an activity but does not show the date and time both in a report. The report's standard functionality doesn't have this feature to show date and time (Both) of activity in a report. In order to achieve this requirement, we can customize this by creating a formula field on activity.

https://help.salesforce.com/articleView?id=000176025&type=1

Regards

All Answers

Alain CabonAlain Cabon
Hi,

Show LAST MODIFIED "TIME" on reports

Salesforce allows us to show the Last Modified DATE on reports, but does not yet allow us to show the Last Modified TIME. Being able to report the TIME that something was modified would be very helpful.

Comment: And still not delivered after 9 years?

https://success.salesforce.com/apex/ideaView?id=08730000000Bre3AAC

Displaying both - date and time of Last Modified Date or Created Date of activity in a report​

The reports can show last modified date or created date of an activity but does not show the date and time both in a report. The report's standard functionality doesn't have this feature to show date and time (Both) of activity in a report. In order to achieve this requirement, we can customize this by creating a formula field on activity.

https://help.salesforce.com/articleView?id=000176025&type=1

Regards
This was selected as the best answer
Maggie LongshoreMaggie Longshore
Thanks, but I am not asking about showing on reports as I stated I know the time does not display. But you are right in that it must be this way because of this limitation. Having this outstanding for 9 years is discouraging.

My question was about reading the report in Apex. In the metadata the Last Modified Date is marked as Reports.ColumnDataType.DATE_DATA and not as Reports.ColumnDataType.DATETIME_DATA. However the time portion is returned in the Reports.ReportDataCell getValue() method.

Examples:

getValue() on DATETIME_DATA field returned 2016-06-01 13:41:55
getValue() on DATE_DATA field (last modified date) returns 2017-08-16 13:46:59

calling this with that value
Datetime d = Datetime.valueOf(obj);
works for the first case yet throws System.TypeException: Invalid date/time: Wed Aug 16 13:46:59 GMT 2017

So because it is labeled as a Date I cannot extract the time portion without writing ugly code.

I am working around it. So you can actually get the time out but it takes a hack.
Alain CabonAlain Cabon
Hi,

Ok, I have worked a lot with the metadata of the report recently too and I don't clearly understand your real need

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_enum_reports_columndatatype.htm

My answer gives you not interesting informations (you already know all that).

Your question is interesting and in apex, we can format a text string like in java even if the precise format for "Wed Aug 16 13:46:59 GMT 2017" is always a problem.

Wed Aug 16 13:46:59 GMT 2017 should be: EEE MMM dd  HH:mm:ss z yyyy

But the method parse(datetimeString) in Apex is very weak and has not a string format as parameter (?) so the code in Apex will be ... ugly indeed if "EEE MMM dd  HH:mm:ss z yyyy" is not one of the allowed formats and you have just that ( I tried to find all the allowed formats and it is very difficult to find, thousands of pages and it'll be missing the point).

All the problem is finally as you noticed ... Reports.ColumnDataType.DATE_DATA and not Reports.ColumnDataType.DATETIME_DATA.

(thanks for the points by the way, I am playing all the games of Salesforce (forum, trailhead and so on). here, the game is to have 2,000 points, I see the finish line, I hope).
 
Regards
Alain
Maggie LongshoreMaggie Longshore
My real need was to note the discrepency and maybe help a future developer parse the report structures.
Glad to give you points - I've never thought much about them here as I am mostly a stack overflow developer.