1

What is the best way to output 3 new dates relative to the first date? For instance, I have a date field called "medication_start" = 1/1/2010. I would like three new dates generated in 3 new fields in 6, 12, and 18 months from the start date.

Period 1 (6 months): 6/1/2010 Period 2 (12 months): 12/1/2010 Period 3 (18 months): 6/1/2011

3 Answers 3

0

You can use views_php module. This module adds a field to the view and it also provides a few tokens. You can use the current row values. Note that you have to insert the main fields before the PHP field and exclude the Price field from display, Then the $results,$data,$row objects will give you the value of the row, Do the mathematical calculations and output the result.

0

You could use something like Computed Field for this or you can write your own custom module. You could hook into node save using hook_node_presave (since it acts on save and presave) and calculate the other 3 fields that you need to save. Either way should work pretty well. You would just use php date functions to calculate the new dates either way. There are a bunch of examples for computed field online and in their documentation you could use to draw inspiration from.

0

you can use math field too:

The Math Field module defines a new field type to dynamically calculate values on entity forms. This is an alternative to Computed Field that does not require the use of PHP Filter.

this works much simpler than Computed field. enjoy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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