Try something like this: :smileyhappy:
Go To Layout [ layout based on the table you are searching ]
Enter Find Mode [ uncheck pause ]
Set Field [ your date field ; Get ( CurrentDate ) ]
Set Error Capture [ On ]
Perform Find [ ]
If [ not Get ( LastError )
..... do whatever with found set or record
I tried working with this but I couldn't get it to work. I am already in the correct layout, I am just trying to make a script that will look at my date field and go to the current date.
Are you dealing with more than one country? ie France, Japan, US, etc.? Each has a different way that the date field is entered (month/day/year vs day/month/year etc)
Also is the field you are searching on made as a date field or a text field? Various people will use various types of date separator : . / - which can cause a text field not to find the records needed. Other situations may be that the date is entered as words. See http://forum-en.filemaker.com/t5/Report-a-bug/Returning-MonthName-in-different-languages-French-or-English/td-p/60204
LaRetta's script should go to the found set of records that shows the current date as long as certain conditions are met, ie the calculation result of the get(currentdate) format matches the data in the field. This does not necessarily always hold true. She does have sound advice, it seems like you may need to tweak it to how the data is stored as the find will search based on the content of the index of the field.
I have the field formatted to show the day of the week, the month, the date of the month and the year. I'm only dealing with usa. I'm just trying to make a script in the existing layout that will go to the current date.
Hrm, ok. So just to make sure we're on the same page (since it's hard to see things through words on the internet),
the field is formatted to : Wednesday, April 21, 2010?
If you click in the field, how does the data look? Does it state 4/21/2010? or does it state Wednesday, April 21, 2010?
If it states Wendesday, April 21, 2010, you will have to modify the find utilizing the get(currentdate) function. ie something like :
MonthName ( Get(CurrentDate) )& " " & Day (Get(CurrentDate)) & ", " &Year(Get(CurrentDate))
When I click into the field it looks like this- 4/21/10
Are you seeing your records in List View ?
Odd, if the field is set to a date field, what LaRetta had stated should work. On a weird note, you can't apply date format unless it's a date field... unless you mean a conditional format. Sort of intriguing.
Anyways, try this calculation :
Month(Get(CurrentDate)) & "/" & Day(Get(CurrentDate)) & "/" & Right(Year(Get(CurrentDate));2)
instead of the regular get(currentdate) calculation with the script LaRetta stated.
The records are in form view.
I'm sure the problem is with me. This must be a simple problem. I am still a database rookie. LaRetta's solution will probably work. I am not sure exactly how to type it in to a calculation. Exactly how to assemble the script is my problem.
"When I click into the field it looks like this- 4/21/10"
If, when you click into the field, it looks like that (2-digit year) then I don't believe it can be a true date field. It is my understanding that FileMaker converts 2-digit years to 4-digit and even if you imported that data into your date field from a text field which had 4/21/10, FM would automatically convert it to 4-digit year.
It is possible that your OS system settings show 2-digit year? I know that system settings can be changed to enter dates with dashes instead of slashes so (maybe) 2-digit year is acceptable? It seems against what FM Help says but then ...
First please verify the data type on that field and make sure it's truly a date because if you have date records with 4/21/10 and it's a true date than searching for Get ( CurrentDate ) would find them.
But here is a sample of the script that you can compare Find Date. Open this file then go to Scripts and click 'Find Today'. Check how it works by clicking on ScriptMaker then selecting 'Edit.' If you are getting stuck anywhere then it is with the Set Field script-step. Notice that there are two parts to the Set Field ... the first, click the target field Specify button and find your field and select it. Then click the 'calculated result' Specify button and simply type: Get ( CurrentDate )
Let us know if you get stuck. I'm with Oki182, it's a bit puzzling, but we'll help you through it.
That's it! Thank you, Thank you. It worked.
I was typing all of this into one calculation which didn't work but the way you just explained using the set field and typing the get (currentdate) work.
Have a great day.