Announcement

Collapse
No announcement yet.

How to calculate days count between two dates

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

  • How to calculate days count between two dates

    Hi,

    I want to calculate and show the date count between tow dates in opportunities.

    Ex-
    Opportunity Life type is int

    Opportunity Life = Current date - Created date


    I have tried different thing, but nothing happen.
    Cheers!
    Nishan.

  • #2
    How and where are you doing this?

    I have a field called "age" defined in the custom clientDefs.json for a Case where I calculate the number of seconds between the current date (NOW) and the "modified_at" field:

    "age": {
    "type": "float",
    "readOnly": "true",
    "notStorable": "true",
    "view": "custom:views/fields/age-since",
    "select": "TIME_TO_SEC(TIMEDIFF(NOW(), case.modified_at))"
    }

    I'm using a custom view here to convert the seconds to hours or days (depending on number of seconds) as well as using differing markup.

    Comment


    • #3
      Hi,
      you can use this formula
      Code:
      oppAge = datetime\diff(datetime\now(), createdAt, 'days')

      Comment


      • #4
        Originally posted by Maximus View Post
        Hi,
        you can use this formula
        Code:
        oppAge = datetime\diff(datetime\now(), createdAt, 'days')
        Hi Maximus,

        your is formula working perfectly. Thank you. But one thing, i need to update this "oppAge" entity automatically each and every day. Is it possible.

        Eg -for today oppAge is 50, for tomorrow it should show as 51.
        Cheers!
        Nishan.

        Comment


        • #5
          You can't achieve such dynamic changes with formula. You can do this with a scheduled workflow.

          Comment


          • #6
            ... or like the example I provided, it updates dynamically.

            Comment


            • #7
              Originally posted by blueprint View Post
              ... or like the example I provided, it updates dynamically.
              Hi blueprint,

              Could you please show me how did you do it for case ? a complete one.

              As maximus says, via schedule workflow it working, but the thing is schedule job update modified date as well. So I need to update opp age by back-end. please help.
              Cheers!
              Nishan.

              Comment

              Working...
              X