Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

My database has a date field showing (example) "deadline" (15/8/2011) etc

I would like to be able to script a find that will show all records that state todays date + the next 7 days?

I have tried the following (//...7) but it shows me results from today until July (7).

Can someone please advise?

Many Thanks

Posted

If by "Script a find" you mean that this find is going to be hard-coded into a script, try setting the field in find mode to


Get( CurrentDate ) & "..." & Get( CurrentDate ) + 7

Posted

If by "Script a find" you mean that this find is going to be hard-coded into a script, try setting the field in find mode to


Get( CurrentDate ) & "..." & Get( CurrentDate ) + 7

Thanks for the reply, but as a novice I am still struggling to work this out.

I will try to explain better what I am hoping to do.

I have a Date field on my records named "deadline" which shows a calendar date 15/8/2011 etc.

I would like to format a button which could run a script that will find me all the records with this date field that equals the current date + 7 Days ahead.

So my records are filtered to only show me what deadlines I need to hit in the next week.

As a novice I need help or advise on how best to format fields and calculations to show this.

Thanks again

Posted

Thanks for the reply, but as a novice I am still struggling to work this out.

I will try to explain better what I am hoping to do.

I have a Date field on my records named "deadline" which shows a calendar date 15/8/2011 etc.

I would like to format a button which could run a script that will find me all the records with this date field that equals the current date + 7 Days ahead.

So my records are filtered to only show me what deadlines I need to hit in the next week.

As a novice I need help or advise on how best to format fields and calculations to show this.

Thanks again

In that case, here are the basics:

First of all, make sure that the Deadline field is set up in your database as a "Date" type. What we're taking advantage of here is the fact that, when given a date range, FileMaker matches a field to all dates within that range. You can specify a date range when searching by using three periods (...) between two dates.

The second thing we're taking advantage of is FileMakers Get functions. Here, Get( CurrentDate ) always returns today's date. Lastly, while FileMaker displays dates in a readable format (such as 5/17/2011), in the background, these dates are actually stored as numbers. Now we can add a number to our date, such as Get( CurrentDate ) + 7, and FileMaker will give us a result of a new date. Get( CurrentDate ) + 7 will result in a date 7 days from now.

Now, we can combine these two ideas to search for a date range. When you search for these dates, you have to have some way of getting the field to say "5/17/2011...5/24/2011". We can build this string by using the ampersand (&) to combine the result of our Get( CurrentDate ) functions with the "...". The calculation to combine these would be


Get( CurrentDate ) & "..." & Get( CurrentDate ) + 7 )





If we make a simple script that sets a field to this value, then running the script will find all records with a Deadline between today and 1 week from today.





Enter Find Mode[]

Set Field[ MyTable::Deadline ; Get( CurrentDate ) & "..." & Get( CurrentDate ) + 7 ]

Perform Find[]

Now create a button on your layout, assign this script to it, and click it whenever you need to.

Posted

In that case, here are the basics:

First of all, make sure that the Deadline field is set up in your database as a "Date" type. What we're taking advantage of here is the fact that, when given a date range, FileMaker matches a field to all dates within that range. You can specify a date range when searching by using three periods (...) between two dates.

The second thing we're taking advantage of is FileMakers Get functions. Here, Get( CurrentDate ) always returns today's date. Lastly, while FileMaker displays dates in a readable format (such as 5/17/2011), in the background, these dates are actually stored as numbers. Now we can add a number to our date, such as Get( CurrentDate ) + 7, and FileMaker will give us a result of a new date. Get( CurrentDate ) + 7 will result in a date 7 days from now.

Now, we can combine these two ideas to search for a date range. When you search for these dates, you have to have some way of getting the field to say "5/17/2011...5/24/2011". We can build this string by using the ampersand (&) to combine the result of our Get( CurrentDate ) functions with the "...". The calculation to combine these would be


Get( CurrentDate ) & "..." & Get( CurrentDate ) + 7 )





If we make a simple script that sets a field to this value, then running the script will find all records with a Deadline between today and 1 week from today.





Enter Find Mode[]

Set Field[ MyTable::Deadline ; Get( CurrentDate ) & "..." & Get( CurrentDate ) + 7 ]

Perform Find[]

Now create a button on your layout, assign this script to it, and click it whenever you need to.

Posted

Thank you so much, that worked great!!

Your time and patience most appreciated!

Posted

Happy to help!

If you'd like to know more about how to write scripts and calculations, I suggest you bookmark the Filemaker 11 Function Reference and the FileMaker 11 Script Step Reference for quick access. Even though functions and scripts are only a part of the power behind filemaker, knowing what sort of tools you have at your disposal is very helpful. These references have certainly helped me countless times!

You might also like to take a look at this blog: http://sixfriedrice.com/wp/the-secret-life-of-find-mode-requests/ which helped me sort out just what you could do with finds, especially with dates and times.

Brian

This topic is 4936 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.