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

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

Recommended Posts

Posted

Hi All,

I am gradually getting a handle on things as I try to build up my scripts in order to get more functionality on the database i am working on, and appreciate the input I have gotten from the community thus far, so thanks for that! I have multiple questions but will try to hone in on a simpler one today. Is there a way to make a field be a date but not require it to be a 4 digit year date? For the type of records I am working (archival materials), each record has two date fields, Date 1 and Date2, and people entering metadata into the database can use those fields to reflect the span of time the archival object represents. However, we can often say that for the archival material we are working with, a specific date is not that clearly known, and if it is, is usually just a given year.

I want the user to be able to search the database within a range of dates that they supply, and see what comes up. I have built a simple script that does that, though it is only looking at the Date1 field in the record, not Date2 (I haven't been able to figure that out yet).

But the issue I am having is that I am not seeing a workaround if people populating the database don't know the 4 digit year date for either Date1 or Date2 for the object. I want them to be able to just enter a year, and I certainly don't want them to have to make up a month and day just to get the field filled out.

Any thoughts? Thanks! Jen

 

Posted

A date field must contain a date - that is a specific day between January 1, 0001 and December 31, 4000. Otherwise it will contain invalid data that you won't be able to use for anything.

To allow your users to enter partial dates, consider using a set of 3 number fields - day, month and year - for each date. Then use calculation fields to produce actual dates for find purposes. For example, for an entry of 1674 (with no month or day) into the Date1 set of fields, calculate the date of January 1, 1674 and for an entry of 9 and 1809 (with no day) into the Date2 set, calculate the date of September 30, 1809.

Another option is to use a text field for the entry, but then you and your users must have an agreed convention for entering partial dates, otherwise you won't be able to parse the entries.

 

  • Like 1
Posted

I set up those three different fields (number fields) and then tried to create a new field called Resulting Date. I gave that field a calculated value and specified the calculation to be:

Month1 & "/" & Day1 & "/" & YR1

but it doesn't seem to care for that. The resulting number is far afield from what I was hoping to create. Any ideas? :)

Posted
42 minutes ago, JenAAAA said:

The resulting number is far afield from what I was hoping

First of all, the result type of the calculation should be Date, not Number.

Next, I recommend you use the Date() function instead of relying on the date format in use. So the calculation would be:

Date ( Month1 ; Day1 ; YR1 )

in its simplest form, and more usefully:

Date ( 
If ( Month1 ; Month1 ; 1 ) ;
If ( Day1 ; Day1 ; 1 ) ;
YR1 
)

 

Posted

Hi, it's still not working for me.

Two questions: 

I have all Month 1, Year1, Day1, etc. all set as Number fields. Is that correct?

The other is that my field called Resulting Date is now a Date field and has a Calculated value under Auto-Enter. Is that the correct place to apply the calculation?

The current result of this set up is a longer number (not a date) so I am not sure where things are breaking down here.

Posted

I prefer to use actual calculation fields for straightforward calculations. Auto-entered values are better suited for situations where the user is allowed to override the calculated value. Still, both should work correctly in this case. See if the attached demo works for you.

PartialDates.fmp12

Posted

I will take a look at that, thanks! I did look into the actual calculation field, but it seemed like it did want to let me enter a date function besides that of Enter date - where it goes and grabs today's date. I will keep trying!

Posted

Yes, thank you, it finally worked!! I tried going over and re-entering the raw dates into my Day, Month, and Year fields and suddenly it worked.

I will keep at it. Thanks so much!

Posted

My test database is working well but I am find that for the actual database I want to modify, that I would like to be able to search a range of years, which I would like to treat as numbers (not dates). Would you recommend using the following script in order to find a range of numbers based on 2 number fields (From_Year) and (To_Year)? (That said, I tried to build this script but FM did not care for parts of it).

If(

GetAsNumber(To) > GetAsNumber(From);

GetAsNumber(From) & ¶ &

NumRange(GetAsNumber(From) + 1; To);

GetAsNumber(From)

)

 

Or do I really have to make say those two fields date fields and use the script that worked above?

Thank you!

 


 

Posted (edited)

I am afraid I have no clue what the code you have posted is supposed to do (and it's certainly not a script).

Earlier you said:

On 4/7/2020 at 10:31 PM, JenAAAA said:

I want the user to be able to search the database within a range of dates that they supply

I took that to mean you want to give them the flexibility to supply the range as full or partial dates. If they will always supply only the FromYear and ToYear, then your task is quite simple, because every record has separate StartYear and EndYear fields - so you just need to find records where: 

StartYear ≤ FromYear
and
EndYear ≥ ToYear

This would be done in an actual script.

But as I said, I thought you wanted to be more flexible than that. I thought you would want to calculate the start and end of the search range in a manner similar to the calculation of the start date and end date discussed earlier, and then search the date fields instead of the year fields. So the user would have the option to search for records in the range from April 15, 1878 to January 28, 1902, or from August 1765 to May 1769, or from 1499 to 1507, or any other combination of full and partial dates.

 

Edited by comment
Posted

OK, thanks for the clarification. That is good to know about the simpler way to search if one is using only Years. I am not entirely sure which way we might go on that. I actually just started adding in the modifications we discussed last week, where month, day, and year are all their own fields and then get combined later into a date.

The script I posted is one I found on the web.

As an aside, when you mention the StartYear and EndYear fields  - are they just sort of built into the database without anyone manually adding them?

Anyhow, thanks a lot!

Posted
1 hour ago, JenAAAA said:

when you mention the StartYear and EndYear fields  - are they just sort of built into the database without anyone manually adding them?

No I meant the input fields that you called Year1 and Year2. I think my names are more descriptive.

 

  • Like 1

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