Jump to content
  • 0

Get Last Day of Month from Date Field - Triggered Actions


kpcollier

Question

I have a date field, Order_Date, in my table. In my Update Triggered Action, I need to get the last day of the month from this Order_Date value. I'll then need to use this value in an IF/THEN block.

In example, if Order_Date = 05/22/2023, then the variable value would output 05/31/2023. If Order_Date = 06/07/2023, the variable would output 06/30/2023.

Any ideas how to do this in triggered actions?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

@DrSimi This is neat. Looks like you're using the system's date math operations in a loop. Once the date gets to the end of the month, the CheckMonth variable would switch to the next month, and that's when you know when you've reached the end of the month. Simply subtract a day from that and there's my answer.

Many thanks for this!

Link to comment
Share on other sites

  • 0

Got an idea after seeing @DrSimi's answer. I was able to make the query shorter in triggered action:

image.png.03ad94d87c373d0564473858cbf30afb.png

I'll try my best to explain how it worked.

It subtracts 1  day short from the original day value to get the first day of the month in the variable. So you can actually name the variable "first day of the month". 
Then, in the update, I simply added 1 month to the variable to get the first day of the next month and lastly, subtracted 1 day to the output date so it gets the day before it which is always the last day of the previous month (which is the month of your original input).

I really hope I am making sense but anyways it worked for month's with 28,30, and 31 as the last day. Cheers!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...