Forum Discussion

bolabuga's avatar
bolabuga
Helper V
9 years ago
Solved

question regarding dates

Good day everyone.   I have the following situation:   We do readings of total water (in M³) used in a month, every month.  The readings are made through the hydrometer installed in each house on...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi bolabuga,

     

    >>Did i understand it right??

    Yes, it is my option.

     

    >>2- Again considering i understood correctly, theres a problem. Depending on the cycle, it can start at 11 and ending at day 9 or start at day 13 and end at day 11. I will write the actual 2016 cycle dates when i have a time window here on job.

     

    It is hard to calculate the cycle range if you use the random days range to calculate it. I can calculate the cycle if you provide a specific range of days and an start date.

     

    For example: 30 day, start date 2015/1/11.

    Measures:

     

    StartDate = DATE(2015,1,11)

     

    DayRange = 30

     

    Current Cycle =
    var currentDate=MAX([Date])
    var cycleCount=DATEDIFF([StartDate],currentDate,DAY)/[DayRange]
    var cycleTotal=INT(cycleCount)+ if(MOD(DATEDIFF([StartDate],currentDate,DAY),[DayRange])>0,1,0)
    return
    if(currentDate>=[StartDate],if(MOD(cycleTotal,12)>0,cycleTotal-INT(cycleTotal/12)*12,if(MOD(cycleTotal,12)=0,12,cycleTotal)),-1)

     

     

    Regards,

    Xiaoxin Sheng