Announcement

Collapse
No announcement yet.

changing date based on criteria

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • changing date based on criteria

    hi all,

    i have the following fields:

    date filed {Prescription Date}
    date filed {Annual Treatment End}
    date filed {End Date}
    integer{plan id] (values 0,1) 0 for Seasonal and 1 for yearly.


    i want to get the following

    if the plan = 0 then
    {Annual Treatment End}= 31-7- Current year from Prescription Date.
    {End Date}= 31-7-3Years from Current year from Prescription Date.
    else
    {Annual Treatment End} = 1 year added to Prescription Date
    {End Date}= 1 year added to Prescription Date
    example,


    Prescription Date: 25/1/2015
    if the plan 0 then
    Annual Treatment End : 31/07/2015
    End Date : 31/07/2018

    Else

    Annual Treatment End : 25/01/2016
    End Date : 25/01/2018

    Thanks in advanced for help

  • #2
    that is easy logic add it to events it will work, make sure to remove the spaces from your fields names, usually your fields should not contain any space.

    something like this (example) create your required field accordingly in db

    Code:
    $treatment1 = strtotime('Y'); //see this http://www.w3schools.com/php/php_date.asp
    $treatment2 =  strtotime('+1 year') // see this http://us2.php.net/manual/en/function.strtotime.php
    
    if ({field1}==0)
    {
    {field2} == $treatment1;
    }
    else 
    {
    {field2} == $treatment2;
    }

    Comment


    • #3
      Thanks Mike for you replay .
      yes it is easy logic, but i am new in programming and i am still learning.

      and i am sure there is a lot of questions to ask , so i am asking you and the others to be kind and bare with me

      Thanks again

      Comment


      • #4
        Dear Mike

        i will do it like this :
        Code:
        $pres_year = date('Y', strtotime({prescription_date}));
        $num_month_for_rest_of_prescription = {plan_num_days};
        if ({treatment_plan_id}==2)
        {
        {end_date} = date('Y-m-d', strtotime('+' . 2 . ' years', strtotime(date($pres_year . '-07-31'))));
        	{annual_treatment_end} = date('Y-m-d', strtotime(date($pres_year . '-07-31')));
        }
        
        else 
        {
        {end_date} = date('Y-m-d', strtotime('+' . 3 . ' years', strtotime({prescription_date})));
        	{annual_treatment_end} = date('Y-m-d', strtotime('+' . $num_month_for_rest_of_prescription . ' days', strtotime({prescription_date})));
                
        }
        i did not try yet but i hope it will work

        Thanks again for your help

        Comment

        Working...
        X