CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Custom data - showing time part of DATETIME custom field
Pages: [1]

Author Topic: Custom data - showing time part of DATETIME custom field  (Read 1157 times)

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Custom data - showing time part of DATETIME custom field
October 13, 2010, 06:05:21 am
Hi to all,

I am customizing a event participant listing report.

Things work brilliantly and after following wiki instructions for customizing reports and enabling

Code: [Select]
protected $_customGroupExtends = array( 'Participant' );
i get access to all of our custom fields.

However, some of these fields contain both date and time, which are fine on the profile forms, but here on the report in only shows the date part.
What would be the best path to properly format this field for display (and where would be the best place to do this).

Best,
Goran

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: Custom data - showing time part of DATETIME custom field
October 13, 2010, 10:33:30 pm
Hi goran,

After looking at the code of report, it seems that custom date fields (date as well as datetime ) are just handled as a date field in the report.
You may raise this issue as a feature request.

Rajan 

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Custom data - showing time part of DATETIME custom field
October 14, 2010, 01:01:17 am
Goran,

For now you can apply below fix:

Code: [Select]
Index: templates/CRM/Report/Form/Layout/Table.tpl
===================================================================
--- templates/CRM/Report/Form/Layout/Table.tpl    (revision 30119)
+++ templates/CRM/Report/Form/Layout/Table.tpl    (working copy)
@@ -75,7 +75,7 @@
                             {elseif $header.group_by eq 'YEAR'}   
                                 {$row.$field|crmDate:$config->dateformatYear}
                             {else}       
-                                {$row.$field|truncate:10:''|crmDate}
+                                {$row.$field|crmDate}
                             {/if}   
                         {elseif $header.type eq 1024}

Please note this will also expose time in other reports which have date fields. So might need to adjust for your report/field.

And please file an issue since it will require handling of datetime type as well (in order to get into core).

thanks
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Re: Custom data - showing time part of DATETIME custom field
October 14, 2010, 08:49:17 am
Hi Deepak,

Thanks for quick response. I've opened CRM-6946.

Since the proposed solution would change other date time fields (I guess I might have worked on the tpl's for particular report instances, but) I opted for a hack:
- created another custom data field of type text and set it to 'view only'
- added UPDATE and INSERT triggers to custom table in mysql that sets this field to

Code: [Select]
date_format(new.original_date_time_field_n, '%H:%i')
Best

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Custom data - showing time part of DATETIME custom field

This forum was archived on 2017-11-26.