Formulas with dates | WordPress.org

[ad_1]

Hello!

Sorry for that, this plugin is very new and not all the features of smart forms have been added yet. Could you tell me which features you are looking to use so i work in adding them? Jut the days between two dates? also could you detail me what you mean with “The same goes for the time”, do you want to make an operation against the time as well?

Hi Edgar,
thank you for such a swift response! 🙂

I am working on a form for equipment rental. Therefore there is a checklist with items and a Date Range.
The calculation is simply the Price of items times days where the first day isn’t counted if rented after 14.00 and the last day isn’t counted if returned before 14.00.

With one exception, for example if rented on day 1 at 17h and returned the following one at 10h, then it should count 1 day. But that is an easy fix with one If – If the result of “days” is 0, then make it 1. 🙂

Thank you!!!

ok so if i understand correctly you first need to get the days between two dates and also the time of a datepicker so you can substract days if they meet a condition?

That would be the best. Regarding the time I think I only need the value of start time and end time and I can compare this value to a condition, what do you think?

But I can work with the difference between days only and put the time info to infobox only. eg. “This price is only valid if you rent after 14 and return before 14”. I don’t know how complicated this is for you 🙂

Got it, last question, are you using two date fields or a date range field?

Right now I have them both in my form at the moment as I was trying to get either of them working. I like the Date range field better, but it doesn’t really matter.

I have two follow-up questions, I hope you don’t mind 🙂

1. How can I translate names of days in the week and months? I have found your Spanish .po so I reduced it to these things and translated, renaming it to end with cs_CZ.po . But that doesn’t roll 🙂

2. I have seen in the source code there is a string with First day of the week, which makes me think I can set it somewhere. But I couldn’t find it.

Thank you!

About the first one, I figured it out partially. For anyone else looking, if you use Loco translate:

Using Loco translate select “All in one forms” in Plugins, go to Configuration and select rednaowooextraproduct.mo as a template instead of the one preselected. Then I could add the Czech language and do the translation with no errors.

Not sure it will show on the front-end yet however.

  • This reply was modified 3 hours, 13 minutes ago by strifer.

Ok please update the plugin, i added a few functions that will let you do that, i think the formula that you need is this one:

if([RNF "10" RNF].GetEndDate()==null||[RNF "10" RNF].GetStartDate()==null)
return 0;

days=RNDateDiff([RNF "10" RNF].GetStartDate(),[RNF "10" RNF].GetEndDate(),true)

days=RNFloor(days)
if(RNDatePart([RNF "10" RNF].GetStartDate(),"H")<14)
  days=days-1

if(RNDatePart([RNF "10" RNF].GetEndDate(),"H")>14)
  days=days-1

return days;

Change “10” for the id of your date range field. Also you might need to clear your temporary internet files to be sure your browser is using the latest files of everything.

Regards!

Hi Edgar,
thank you! I will try as soon as I can download the update, there is only 1.2.39 available at the moment.

I will let you know ASAP.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer