how can i sync dates in a column with formula?

Hello,

below, I will explain to you the calculation of the termination notice period before the expiry of a contract and the sending of the reminder e-mail to the responsible person according to this notice period;

1- In the first step, I enter the end date of the contract and the notice period on a daily basis.


image.png

2- The "Deadline for Notice of Termination" field has been formulated according to the notice period. According to the situation in the example, it will send a reminder e-mail to the responsible person 6 months in advance.

的formula in the "Deadline for Notice of Termination" field is as follows;

=[Current Contract End Date]@row - [Termination Notice Period (Days)]@row


So far everything is normal and working. (notifications etc.)

If you notice, the contract expiry date is 5.8.2024. Since 6 months notice is requested, the date is expected to be 5.2.22024.

but the date is 7.2.2024.

I tried removing the weekends to fix this situation. but then it crushes the formula in the "Deadline for Notice of Termination" column.

image.png


I would be very happy if you could support me in this matter.


thanks

Best Answer

  • Kelly Moore
    Kelly Moore ✭✭✭✭✭✭
    Answer ✓

    Hello@marcusben

    日期的差异是因为所有月不t always have 30 days in them.

    Here's one approach that will force the day to equal the Contract end date. This works if you are working in whole month increments. If, for example, the notice was going out 45 days earlier then the formula might not make sense. We could adjust it to make it more robust but it would make it more complicated - and it would never be 100% accurate.

    =IF(DAY([Current Contract End Date]@row) = DAY([Current Contract End Date]@row - 180), [Current Contract End Date]@row - 180, DATE(YEAR([Current Contract End Date]@row - 180), MONTH([Current Contract End Date]@row - 180), DAY([Current Contract End Date]@row)))

    This looks at the day to see if the subtraction product ends up with the same day. If yes, simply do the subtraction. If no, reconstruct the date value so that it will match.

    Kelly

Answers

  • Kelly Moore
    Kelly Moore ✭✭✭✭✭✭
    Answer ✓

    Hello@marcusben

    日期的差异是因为所有月不t always have 30 days in them.

    Here's one approach that will force the day to equal the Contract end date. This works if you are working in whole month increments. If, for example, the notice was going out 45 days earlier then the formula might not make sense. We could adjust it to make it more robust but it would make it more complicated - and it would never be 100% accurate.

    =IF(DAY([Current Contract End Date]@row) = DAY([Current Contract End Date]@row - 180), [Current Contract End Date]@row - 180, DATE(YEAR([Current Contract End Date]@row - 180), MONTH([Current Contract End Date]@row - 180), DAY([Current Contract End Date]@row)))

    This looks at the day to see if the subtraction product ends up with the same day. If yes, simply do the subtraction. If no, reconstruct the date value so that it will match.

    Kelly

  • Hello@Kelly Moore,

    you said;

    日期的差异是因为所有月不t always have 30 days in them.


    Yes, I've thought about this. I just didn't write. The following formula sought to work. so thanks


    I just made a small change;

    I added -"Termination Notice Period (Days)" instead of 180.

    because in some cases instead of 180 it's 270, 320 etc. it could be.


    have a nice day

  • Hello@Kelly Moore,

    I have identified some situations, i would like to share for your help;


    1- When a warning is requested 6 months (180 days) before the contract will expire on 31 December, July is calculated instead of June. I thought because my guess is that June doesn't turn 31 here. but when this happens, it is delayed by 1 month. This means that the reminder mail is delayed.

    image.png


    2- I have determined the termination notice period of 720 days for the contract that will expire on 21.2.2024. I expected it to return to 21.2.2022, but it does 21.3.2022. If I log in as 730 days (exactly 2 years) then it gives the correct date. (not on the weekend)

    When we look at example b, I see that it has provided the correct return for 720 days.

    example a:

    image.png

    example b:

    image.png


    3- In this example I expect it to go to March 30th. but I'm not sure if it was postponed by 1 month because it coincided with the 30th of March weekend.

    image.png


    thanks for your help

  • Kelly Moore
    Kelly Moore ✭✭✭✭✭✭

    嘿,马克

    Sorry for the delay. This took a bit to work out. There are numerous posts regarding how to add months - it gets complicated since one has to account for the changing year value, something that is automatically managed when straight days are added to a date. We can give this a go to see if it gets you closer. There are many functions that smartsheet does very well and there are some other functions that are still developing. The function of Time, in general, is still a developing function within smartsheet.

    I added two new helper columns - we could incorporate these formulas into a single formula perhaps in the end, but whenever I have a complicated formula I try to break the formula into steps so I can watch the failure modes more closely. The two helper columns are for this purpose.

    [Number of Months]

    =INT([Termination Notice Period (Days)]@row / 30)

    [Number of Years]

    =INT([Number of Months] + MONTH([Start Date]@row)) / 12)

    的INT() function will take a value that might have a decimal in it to a whole number.


    Once the helper columns are added, let's try this formula. The formula looks first to see if the dates cross years. If yes, then the years and months are adjusted. If no, it simply adds months together.

    =IF(OR(MONTH([Start Date]@row) + [Number of Months]@row > 12, [Number of Months]@row >= 12), DATE(YEAR([Start Date]@row) + [Number Years]@row, ((MONTH([Start Date]@row) + [Number of Months]@row) - ([Number Years]@row * 12)), DAY([Start Date]@row)), DATE(YEAR([Start Date]@row), MONTH([Start Date]@row) + [Number of Months]@row, DAY([Start Date]@row)))

    Will this work for you?

    Kelly

  • Hey@Kelly Moore,


    thank you for your last formul... I encountered 2 different problems here;

    1-

    的"Deadline for Notice of Termination" field must be smaller than the "Start date" field. it should be calculated according to the value entered in the "Termination Notice Period (Days)" column.

    For example, as seen on the picture

    "Termination Notice Period (Days)" = 60 days

    so

    的date in the "Deadline for Notice of Termination" field should show 60 days ago.


    image.png


    2- When I enter 240 days or more in the "Termination Notice Period (Days)" field, the formula breaks down as seen in the picture below. Normally according to the contract information I get here 720, 900 days etc. can enter.


    image.png


    really thank you so much

    Marcus

  • Kelly Moore
    Kelly Moore ✭✭✭✭✭✭

    嘿,马克us

    Let's see how close we can get to what you want. I'll mention again that because we're making some assumptions on number of days in a month and/or number of days in a year, we will never be completely accurate.

    I found a mistake in what I gave you as Number of Years - hopefully you had already corrected the missing parenthesis.

    =INT(([Number of Months]@row + MONTH([Start Date]@row)) / 12)

    Once that was fixed, this original formula works for me on all dates*

    =IF(OR(MONTH([Start Date]@row) + [Number of Months]@row > 12, [Number of Months]@row >= 12), DATE(YEAR([Start Date]@row) + [Number of Years]@row, ((MONTH([Start Date]@row) + [Number of Months]@row) - ([Number of Years]@row * 12)), DAY([Start Date]@row)), DATE(YEAR([Start Date]@row), MONTH([Start Date]@row) + [Number of Months]@row, DAY([Start Date]@row)))

    But, I think I became confused what date you are looking for. *My formula is adding the number of days (Termination Notice Days) onto the Start date. Do you mean this value should be subtracted from the start date?

    This is where I had your formula as I tested it

    image.png

    Please clarify for me what columns are added and/or subtracted and from what days.

    Kelly

  • Hello@Kelly Moore,


    thanks for your support.

    I want to clear up a misunderstanding. Maybe there was a mistake in my statement. The field i call "Start Date" is actually the current end date of the contract. This field triggers the "Deadline for Notice of Termination" field. so ;

    的"Deadline for Notice of Termination" field should be small in the "start date" field. accordingly, if 90 is entered in the "Termination Notice Period (Days)" field, as in the example below, i need to see 90 days before the date of 31.5.2022 in the "Deadline for Notice of Termination" field. like february 2022... etc

    image.png


    thanks

    Marcus

  • Kelly Moore
    Kelly Moore ✭✭✭✭✭✭

    嘿,马克

    Have you tried the Workday() function?

    =Workday([Start Date], 0-[Termination Notice Period (Days)]@row)

    does this do what you want?

    Kelly

  • Hi Kelly Moore,

    Sorry these studies didnt work for me... :(

    thanks, have a nica day

    Marcus

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
=[End Date]@row - [Start Date]@row<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":254,"urlcode":"Formulas","name":"Formulas"}]},{"discussionID":108271,"type":"question","name":"Conditional formula - if a date is less than 30 days from today","excerpt":"I'm trying to create a conditional formula to flag if less than 30 days from today. I create a separate column to calculate but I am getting an error on the formula. =IF(AND([Event Date] > TODAY(), [Event Date] <= TODAY() + 30), \"Less than 30 days from today\", \"More than 30 days from today\") Help?","snippet":"I'm trying to create a conditional formula to flag if less than 30 days from today. I create a separate column to calculate but I am getting an error on the formula.…","categoryID":322,"dateInserted":"2023-07-28T18:21:58+00:00","dateUpdated":null,"dateLastComment":"2023-07-28T19:22:21+00:00","insertUserID":159884,"insertUser":{"userID":159884,"name":"Connie Cochran","url":"https:\/\/community.smartsheet.com\/profile\/Connie%20Cochran","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-28T19:21:59+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"},"updateUserID":null,"lastUserID":159884,"lastUser":{"userID":159884,"name":"Connie Cochran","url":"https:\/\/community.smartsheet.com\/profile\/Connie%20Cochran","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-28T19:21:59+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":4,"countViews":23,"score":null,"hot":3381143059,"url":"https:\/\/community.smartsheet.com\/discussion\/108271\/conditional-formula-if-a-date-is-less-than-30-days-from-today","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/108271\/conditional-formula-if-a-date-is-less-than-30-days-from-today","format":"Rich","lastPost":{"discussionID":108271,"commentID":387894,"name":"Re: Conditional formula - if a date is less than 30 days from today","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/387894#Comment_387894","dateInserted":"2023-07-28T19:22:21+00:00","insertUserID":159884,"insertUser":{"userID":159884,"name":"Connie Cochran","url":"https:\/\/community.smartsheet.com\/profile\/Connie%20Cochran","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-28T19:21:59+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-07-28T19:21:56+00:00","dateAnswered":"2023-07-28T18:55:42+00:00","acceptedAnswers":[{"commentID":387890,"body":"

Try this:<\/p>

=IF(ISDATE([Event Date]@row), IF(AND([Event Date]@row > TODAY(), [Event Date]@row <= TODAY(30)), \"Less than 30 days from today\", \"More than 30 days from today\"), \"//www.santa-greenland.com/community/discussion/comment/\")<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]},{"discussionID":108267,"type":"question","name":"Combining IF Formula for Blank\/ Not Blank Cells","excerpt":"I want to create a formula that provides the below statuses: -Complete: Based on \"Collected Date\" not null -Incomplete: Based on \"Collected Date\" null and \"Antcipated Collected Date\" null -Pending: Based on \"Anticipated Collcted Date\" not null and \"Collected Date\" null Below is what I have, but it's unparseable:…","snippet":"I want to create a formula that provides the below statuses: -Complete: Based on \"Collected Date\" not null -Incomplete: Based on \"Collected Date\" null and \"Antcipated Collected…","categoryID":322,"dateInserted":"2023-07-28T17:23:40+00:00","dateUpdated":null,"dateLastComment":"2023-07-28T18:28:47+00:00","insertUserID":164288,"insertUser":{"userID":164288,"name":"brownrobe","url":"https:\/\/community.smartsheet.com\/profile\/brownrobe","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-28T18:42:06+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":164288,"lastUser":{"userID":164288,"name":"brownrobe","url":"https:\/\/community.smartsheet.com\/profile\/brownrobe","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-28T18:42:06+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":36,"score":null,"hot":3381135147,"url":"https:\/\/community.smartsheet.com\/discussion\/108267\/combining-if-formula-for-blank-not-blank-cells","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/108267\/combining-if-formula-for-blank-not-blank-cells","format":"Rich","lastPost":{"discussionID":108267,"commentID":387885,"name":"Re: Combining IF Formula for Blank\/ Not Blank Cells","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/387885#Comment_387885","dateInserted":"2023-07-28T18:28:47+00:00","insertUserID":164288,"insertUser":{"userID":164288,"name":"brownrobe","url":"https:\/\/community.smartsheet.com\/profile\/brownrobe","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-28T18:42:06+00:00","banned":0,"punished":0,"private":false,"label":"✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-07-28T18:30:11+00:00","dateAnswered":"2023-07-28T18:22:11+00:00","acceptedAnswers":[{"commentID":387882,"body":"

Greetings @brownrobe<\/a>,<\/p>

Here is a possible solution for your formula:<\/p>

=IF(NOT(ISBLANK([Recovery Collected Date]@row)), \"Complete\", IF(AND(ISBLANK([Recovery Collected Date]@row), ISBLANK([Anticipated Collection Date]@row)), \"Incomplete\", IF(AND(NOT(ISBLANK([Anticipated Collection Date]@row)), ISBLANK([Recovery Collected Date]@row)), \"Pending\", \"//www.santa-greenland.com/community/discussion/comment/\")))<\/p>

Please confirm I have your column names correct and adjust as needed.<\/p>

I hope this helps, and have a great weekend.<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]}],"initialPaging":{"nextURL":"https:\/\/community.smartsheet.com\/api\/v2\/discussions?page=2&categoryID=322&includeChildCategories=1&type%5B0%5D=Question&excludeHiddenCategories=1&sort=-hot&limit=3&expand%5B0%5D=all&expand%5B1%5D=-body&expand%5B2%5D=insertUser&expand%5B3%5D=lastUser&status=accepted","prevURL":null,"currentPage":1,"total":10000,"limit":3},"title":"Trending in Formulas and Functions ","subtitle":null,"description":null,"noCheckboxes":true,"containerOptions":[],"discussionOptions":[]}">

Trending in Formulas and Functions