# Addition and subtraction with dates

is there any way to make additions with current date? for example if I want to know if an order is due in the next 2 days, when I compare today’s date against the due date of that order it should be today’s date + 2, but I don’t know how to achieve that in samba, or if there’s a way to run SQL functions in a rule that would be helpful too.

Thank you

Yes but you need to add seconds. Let me look it up it’s on here somewhere.

Here is an example.

`[=FD(ADS('{TICKET DATE:HH:mm}',+{TICKET TAG:Pickup Minutes}*60),'hh:mm tt')]`

Thank you very much, can you explain to me what =FD and ADS means? I would like to understand better the operation.

In this case I actually took a string multiplied it by 60 the. Added that to the first date. Then I formatted it to show as 03:23 PM with hh:mm tt

1 Like

Thank you so much sir. I appreciate it

The tt in the format displays am or pm

So if I want to add 2 days to the current date I need to breakdown days in seconds?

I’m basic terms that expression takes ticket date formats it as hh:mm then it takes the value in the ticket tag multiplies it by 60 to convert it to seconds and that is added to ticket date. Then I formatted it to show as hh:mm tt

1 Like

Understood, I will play around with it to get the hang of it, again thanks a lot

1 Like

Yes I prefer seconds it’s more accurate and easy conversion. But you are right.

1 Like

I was playing around with it, and I was able to make the addition with ticket tag, but is there any way to add days to the current date? for instance using {DATE} and add 2 days?

Make sure you are using the right date/time format in the Format Date. Here is quick reference to date/time formatting:

Using Jesse’s formula, you would want to use something like this:
`[=FD(ADD('{DATE}',+2),'MM/dd/yyyy')]`
or this
`[=FD(ADD('{DATE}',+2),'ddd MM/dd/yyyy')]`

4 Likes

Yes my example combined a couple things before it added. It may have confused you as you really needed something a little simpler like what he just demonstrated.

Excellent reference, thank you very much