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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Contact Created Date
Pages: [1]

Author Topic: Contact Created Date  (Read 1680 times)

kyle2012

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: 1.7
  • MySQL version: 5
  • PHP version: 5
Contact Created Date
January 17, 2012, 01:21:34 am
How can I display the created date of a contact  in the summary?

Alternatively, how do I get the first record in the change log which presumably would be the created date?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Contact Created Date
January 17, 2012, 10:38:51 pm
Quote
How can I display the created date of a contact  in the summary?
Alternatively, how do I get the first record in the change log which presumably would be the created date?
civicrm_log table stores the changes for contact. Below sql should give you created date:

Quote
SELECT `modified_date` FROM `civicrm_log` WHERE entity_table="civicrm_contact" and entity_id=102 order by modified_date limit 1

where 102 is contact id

Then use contact summary hook to add this information on summary page.
http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmsummary

Hth
Kurund

Found this reply helpful? Support CiviCRM

websynapse

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 3
    • Ryan Kennedy
  • CiviCRM version: 4.3.7
  • CMS version: Drupal 6
Re: Contact Created Date
March 12, 2012, 03:37:09 pm
How can you tell if this is the created or modified date? I'm doing comparisons with Advanced Search 'Added' vs 'Modified' and this seems to catch both.

EDIT: OK I can see that that query shows only the first 'modified by' date, which limits the search to when a single contact was created.

I'm trying to build a query that shows me how many contacts were created over time periods - can anyone help please?

This catches all contact modifications:

Code: [Select]
select count(*), left(modified_date, 7) as month
    from civicrm_log
    where modified_date like '2012-%-%'
    and entity_table="civicrm_contact"
     group by month
     order by month desc;

I think it needs something like after where modified_date like '2012-%-%' that says: 'and only if it is the first modified date for this contact' but I don't know how to say that in mysql.
« Last Edit: March 12, 2012, 03:48:38 pm by websynapse »

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Contact Created Date
March 13, 2012, 03:27:12 am
IMO, we should add an enum action field to put ADD,UPDATE,DELETE, would make it way easier, even when using the "complete" log system

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

websynapse

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 3
    • Ryan Kennedy
  • CiviCRM version: 4.3.7
  • CMS version: Drupal 6
Re: Contact Created Date
March 13, 2012, 03:57:21 pm
I agree, some help with my query would be nice though...

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Contact Created Date

This forum was archived on 2017-11-26.