number of days calculation wrong with date

Comments

6 comments

  • Rainer Grabowski

    Hi Veluswami,

    open an item where the vlaue in column 5 is wrong. Click Modify Template, then click into the column 5 field and enter a blank space at the end - does the preview show an error notification? Please share a screenshot of the calculation.

    Rainer

    0
    Comment actions Permalink
  • Veluswami Ganesh

    Dear Rainer,

    Thanks for the reply

    Please find the screenshot after entering a blank space in calculation field

    It doesn't show any error

    i derive the dates also through calculations

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hello Veluswami,

    calculations with date/time values can be very frustrating.

    You pull data with @all of date field  - it seems there is always only 1 item related so it pulls always only 1 date value - right?
    If so you can use @max of date field instead of @all of date (then you don't need the moment() part). 

    If you want to keep the @all of date field - do these date fields have a time value in it? If not, remove the time zone part before .toDate() .

    If the other calculations then show the right result - ok.

    If not try to calculate the diff in hours not in days:

    var diff = moment(prod).diff(moment(picd), "h") /60
    Math.ceil(diff)

    Rainer

    0
    Comment actions Permalink
  • Veluswami Ganesh

    Dear Rainer,

    Tried that also, not working

    the difference should be 2 days

    but it is showing as 1 day, really frustrated

    0
    Comment actions Permalink
  • Rainer Grabowski

    Sorry, my mistake. It's not /60 but /24

    0
    Comment actions Permalink
  • Veluswami Ganesh

    Thanks a lot Rainer, it worked !!

    You are great !!!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk