Jump to content

Date Range Script


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

Recommended Posts

I am trying to write a script that finds a range of records between StartDate and EndDate fields. I have a Date Created field which is what I wound the search to be done on.

I tried using this:

Enter Find Mode []

Set Field ["Date Created", "StartDate"]

Paste Literal ["Date Created","..."]

Paste Result ["Date",EndDate"]

Perform Find []

Like the June 5 post from ZuperZZ suggested, but I quickly found out that my version of FM does not have the Paste Literal command in Scriptmaker. Am I missing something (i.e. I'm stoopid) or is it really not there..

Or is there another way to achieve this?

Thanks to all who reply.

Link to comment
Share on other sites

In their infinite wisdom, FMI has decided to change the names of script steps to alternate names which are not more descriptive than the original names for some totally unknown reason.

Instead of Paste Literal try to Insert Text script step. Make sure the script selects a layout on which the field appears before executing this script step. "Paste" and "Insert" won't work unless the field appears on the current layout. -bd

Link to comment
Share on other sites

liveOak,

I can see how this will work, but when I plug it into my script, the script , the Insert Text command pastes the "..." over the whole field, eliminating the StartDate value. I double checked that the "select" option is OFF, but it makes no difference. Is there a cursor command that I need to use to ADD the inserted text into the field after the StartDate value has been set to the field? I then need to add the EndDate field value into the DateCreated field AFTER the range command. I just don't know how to get around this.

Thanks for your response LiveOak.

Link to comment
Share on other sites

Try using the Insert Calculated Result script step instead, and generate the whole search string in one hit.

Start Date & "..." & End Date

This way you don't have to muck around with the "date Created" and "Date" fields like you did in the example you gave. Just pop the fields directly into the calculation and go.

Link to comment
Share on other sites

  • 2 years later...

Hi All,

I am streamlining an old database I made to get rid of copy and paste steps, but am stumped on daterange step for finds. Came up with a few old posts addressing the question (like this one), but it doesnt seem to work for me.

insert calculated result[select "d_date", "g_datefind1&"..."&g_datefind2"]

does not do the trick, neither does any combination of text to date functions that I have tried with the above fields/data.

d_date is a date field

g_datefinds are date fields

Have things changed, is the above posts in the thread incorrect, or is it too early in the a.m. for me?

-Raz

-Edited-

Oh, I suppose it is too early...

DateToText(g_datefind1) & "..." &DateToText(g_datefind2)does the trick. Not really sure why though.

Link to comment
Share on other sites

DateToText(g_datefind1) & "..." &DateToText(g_datefind2)does the trick. Not really sure why though.

Because the "insert" script steps are similar to typing the date manually, the date field wants the date formatted a certain way (as if we were typing it).

DateToText() converts the date from the way it is stored to the way we (and the field) understand it.

Link to comment
Share on other sites

The Set Field script step requires the data that is being set to be of the same format as the destination field - so it rejects things like "..." and "<" as being non-date characters. Insert Calculated Result is the way to go. If you download my Handy Bits file in the Samples section of this forum (it will be on page 2 or 3 by now - and pick the last one on the list) you will see lots of examples under the date tab of how to script finds for date ranges.

Link to comment
Share on other sites

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