1

I am working on a database system with Drupal 7. I have node types employee, experience etc. With relationship (reference entity), each employ may have zero or more records in experience. Experience node type has a date field (with start and end date) and what I want is to

  1. Calculate a duration or each experience record from stat and end date.
  2. Calculate total experience (sum of durations)
  3. Display total experience (that is sum of the durations) in view of employee with other fields of employee

Example;

Employee VIEW
E_code, Ename, total experience
1 xyz 2 years and 3 months
2 nmn 6 months
3 abc 1 year 7 months

Employees records
Ecode, Ename, Ephone, etc.
1 xyz 5458254 etc
2 nmn 59457495 etc
3 abc 45749 etc
. . . . .and so on

Experience records
E_code, exp_date
1 01/01/2010 to 01/03/2011
2 01/01/2011 to 30/06/2011
1 01/06/2012 to 30/09/2013
. . . . and so on

How to bring total experience of each employee in the Employee table View?

Another question how we refer node field i.e. exp date for global math expression or computed field? In other view i have date field and need subtract that from current date (now?) I thought the global math expression can do that by joint_Date - Now. But not sure. Note I don't need to save this duration in field it should appears in view on go.

Thanks in advance.

0

Hope this will help you, you can use computed_field for calculating the field or you can use the Views Calc.

  • Madhujya can you explain bit more, I am using views Calc which calculate the sum of a column/field, may be I can use aggregation with calc to group sum of each employee. if it were one node type it could be easy, but the main node type is employee (for which I have to make view) and sum of experience from experience node type need to be displayed in the employee view. If my questions is not clear may I rewrite ? – user21354 Jan 3 '14 at 12:58
  • could you please provide me a screen shot of you view, May be i can help you, Provide the screen shot by editing your question and please mension what you want clearly on the screenshot – madhurjya Jan 3 '14 at 13:21
  • There is no screen shot as no view created yet. there 2 tables (node types) 1.employe 2.experience, experience has many experience records with start and end date and employee has single record of each employee. Now what I want to display the total experience of all employee summing from their experience table. first I have to calculate the duration of experience of each record from start and end date then sum this experience of each employee and display with employee information. the experience is connect with employee by Reference field. – – user21354 Jan 6 '14 at 4:33
  • any help, or may I re-write the questions if this is not understandable? – user21354 Jan 7 '14 at 8:09
  • Sorry for late reply, in Views_calc you can able to add a new field in your view, By calculating the difference of the two date field in the views Calc page, Than you can use the hook_views_pre_render(&$view) for calculating the days months and year to render to your view, use the php floor function to implement. – madhurjya Jan 8 '14 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.