Here's a tricky one: I'm trying to create a computed date field. The reason to do it this way round and not compute 'duration_years from $end_date - $start_date)' is for ease of UI ...:P

The task is this:
- field_start_date is a date CCYY.MM.DD
- field_duration_years is an integer representing number of years
- field_end_date is a date CCYY.MM.DD calculated by adding field_duration_years to field_start_date

So my first attempt looks like: $node_field[0]['value'] = $node->field_start_date[0]['value'] + $node->field_duration_years[0]['value']; but - not too suprisingly - it doesn't work :)

I also get an SQL warning on viewing the node -
user warning: Unknown column 'field_end_date_value' in 'field list' query: SELECT field_end_date_value AS value FROM content_type_asset WHERE vid = 41 in /drupal/includes/database.mysql.inc on line 172. Don't know what that's about :(

Q1: I suspect the SQL datatype is a problem, but I know nothing about this sort of thing - perhaps this is a feature request ?

Q2: I wonder if the 'add' operation could be done numerically (simply) by using a unix timestamp(?) format for field_start and then adding the multiples of field_lifespan? Any advice ?

Comments

JohnG-1’s picture

Status: Active » Closed (fixed)
warmiboa-1’s picture

Title: computing date fields ? » same problem
Version: 5.x-1.1 » 6.x-1.0-beta4
Status: Closed (fixed) » Active

This is an old issue, but I need to do the same thing here. Could you manage to get this using and interger representing the duration?

I am using the Duration module, so I would need to:

- field_fecha_inicio_traslado is a date CCYY.MM.DD
- field_duración is a duration field
- field_posible_llegada should be a date CCYY.MM.DD calculated by adding field_duracion to field_fecha_inicio_traslado

warmiboa-1’s picture

This is an old issue, but I need to do the same thing here. Could you manage to get this using and interger representing the duration?

I am using the Duration module, so I would need to:

- field_fecha_inicio_traslado is a date CCYY.MM.DD
- field_duración is a duration field
- field_posible_llegada should be a date CCYY.MM.DD calculated by adding field_duracion to field_fecha_inicio_traslado

1kenthomas’s picture

Title: same problem » computing date fields ?
Issue summary: View changes

(Is v6 still supported?)

dqd’s picture

Status: Active » Closed (outdated)

Due to the Drupal core life cycle policy and security support advisery, Drupal 6 is no longer supported. So issues for Drupal 6 cannot be longer maintained. The project maintainer has asked for closing all D6 issues to clean up the issue queue. Feel free to reopen the issue if required or set it to "needs to be ported" and latest D8 dev version, if the issue discusses a still missing feature which can be implemented in the D8 version.