Jump to content
Server Maintenance This Week. ×

Date Parameter


This topic is 5105 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I apologize if this has been covered. I searched & didn't find anything. Could have missed it though.

Writing our first Custom Function. My background is in C, C#, Java & what not. Logic isn't an issue.

We have a 30 Day billing month & I am moving our date diff logic into a single function.

No matter what I do, I cannot get the Date Parameters to read in the function correctly. I have tried GetAsNumber for the parameter & GetAsDate in the function. I've tried all sorts of combinations. No luck.

I have hard coded the dates, in the function, and it works. Such as Date (5,1,2010). I even hard coded the parameters the same way...and it worked.

The fields I am using are defined as dates. I have used GetAsDate on them, with no luck. They even have full 4 digit years.

Something is wrong with the data, but here is a copy of the function:

Let( [ $dd2 = Date2;

$dd1 = Date1

];

(Year( $dd2 ) * 360 + Month( $dd2 ) * 30 + If( Day( $dd2 ) > 29; 30; Day ( $dd2 ) ) )-

(Year( $dd1 ) * 360 + Month( $dd1 ) * 30 + If( Day( $dd1 ) > 29; 30; Day( $dd1 ) ) )

)

Any help is always appreciated.

Link to comment
Share on other sites

"The fields I am using..."

Custom functions do not use fields.

They take parameters passed to the function.

Try posting a simple example file with the function in it.

Link to comment
Share on other sites

Say you create the custom function Add( N1; N2)

The function calc is N1 + N2

When you call the function you specify fields or variables to pass to it.

In your Invoices table, you could create a field InvoiceTotal, with a calc that uses your custom function:

Add( Invoice::subtotal; Invoice::tax )

Link to comment
Share on other sites

Thanks Bruce. As soon as I hit the Submit Button, I knew something would pop up.

I had two date fields, with very similar names...was using the wrong one. Duh.

All good now.

If anybody new to date logic needed some 30 Day Billing period logic, at least it is now posted.

Link to comment
Share on other sites

Also there is nom reason to use $variables in the Let function. In fact there are good reasons NOT to use $variables, because their scope can extend outside the CF.

It could be changed to:

Let( [ dd2 = Date2;

dd1 = Date1

];



(Year( dd2 ) * 360 + Month( dd2 ) * 30 + If( Day( dd2 ) > 29; 30; Day ( dd2 ) ) )-

(Year( dd1 ) * 360 + Month( dd1 ) * 30 + If( Day( dd1 ) > 29; 30; Day( dd1 ) ) )

)

Link to comment
Share on other sites

Thanks Vaughn. I did know that, but I was otherwise distracted. Now that the dates are correct, I can do without those variables completely.

We just converted over from Version 6 a couple weeks ago. Getting up to speed.

Link to comment
Share on other sites

If you have a full version of FMP 6 there was someone looking to buy a copy.....

http://fmforums.com/forum/showtopic.php?tid/214687/pid/356112/post/last/m/1/#LAST

Just thought I'd pass it along

Link to comment
Share on other sites

This topic is 5105 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.