Jump to content

Recommended Posts

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

 

Link to post
Share on other sites

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
Link to post
Share on other sites

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? :)

Link to post
Share on other sites
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 
)

 

Link to post
Share on other sites

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.

Link to post
Share on other sites

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

Link to post
Share on other sites

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!

Link to post
Share on other sites

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!

 


 

Link to post
Share on other sites

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
Link to post
Share on other sites

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!

Link to post
Share on other sites
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
Link to post
Share on other sites

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
  • Similar Content

    • By ggt667
      Is there a way to query CWP using FMPXMLRESULT as payload to create new records in FileMaker? Goal is to be able to insert records from command line using curl from FMPXMLRESULT files to avoid a somewhat clunky query from FileMaker XML import.
      I tried the following:
      cd /tmp/ curl -X POST -kL -o /tmp/findany.fmpxmresult.xml "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml?-db=PushTest&-lay=Table&-findany" curl -X POST -kL --data @findany.fmpxmlresult.xml "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml?-db=PushTest&-lay=Table&-new" A new record is created, however the payload is ignored.
      Payload below FTR
      <?xml version="1.0" encoding="utf-8" standalone="no"?><!DOCTYPE FMPXMLRESULT PUBLIC "-//FMI//DTD FMPXMLRESULT//EN" "http://127.0.0.1/fmi/xml/FMPXMLRESULT.dtd"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <ERRORCODE>0</ERRORCODE> <PRODUCT BUILD="03/16/20" NAME="FileMaker Web Publishing Engine" VERSION="18.0.4.428"></PRODUCT> <DATABASE DATEFORMAT="MM/dd/yyyy" LAYOUT="Table" NAME="PushTest" RECORDS="17" TIMEFORMAT="HH:mm:ss"></DATABASE> <METADATA> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name" TYPE="TEXT"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="number" TYPE="NUMBER"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="date" TYPE="DATE"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="timestamp" TYPE="TIMESTAMP"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="time" TYPE="TIME"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="_global" TYPE="TEXT"></FIELD> </METADATA> <RESULTSET FOUND="1"> <ROW MODID="13" RECORDID="24"> <COL> <DATA>Sweet</DATA> </COL> <COL> <DATA>667</DATA> </COL> <COL> <DATA>06/05/2020</DATA> </COL> <COL> <DATA></DATA> </COL> <COL> <DATA>10:44:15</DATA> </COL> <COL> <DATA></DATA> </COL> </ROW> </RESULTSET> </FMPXMLRESULT> If I simply put the parameters after the "?" in the payload file it works, however INSERTing the actual FMPXMLRESULT would be desirable.
      curl -X POST -kL --data @/tmp/GETlike.txt "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml" Where /tmp/Getlike.txt contains
      -dbnames as pr example returns expected list of database names.
    • By Msaeed
      Hi All,
      I would like to find solve my issue, as mentioned on the topic of how can find more than fields like serial No. or Code by IOS camera. please find below the script.
       
       
       
      thank in advance for any help or support  
    • By tomp
      I'm having a problem getting BE_SMTPsend to successfully send an email with an attachment.
      No problem sending without an attachment, but when I add an attachment, I get an error 2 (not sure exactly what that means, but without the attachment, no error)
      These are the argument strings with and without attachments:

      I have tried both relative and direct file paths for the variable $attachment. Examples are:


      Both of them return an error code of 2.
      Since the 'send' without an attachment works, all the values of the fields/variables other than $attachment must be valid.
      Can anyone offer a suggestion as to what might be going on and what I might try to resolve this?
       
    • By Msaeed
      Hi All,
      As per mentioned on topic, in fact i would like to create icon ex. hour in case rigging guard the insert time.

    • By Solvax
      Hi,
      I'm trying to make a subsummary report with data from the current table and a related table.
      I never get to display the correct totals for the related table, and would therefore appreciate your help.
      First I'll try to explain the workflow:
      I have two tables called 'Voorraad_uit' (= outgoing stock) and 'Voorraad_in' (= incoming stock) which are related by delivery number.
      Data is first entered in 'Voorraad_in' (= incoming stock) and then related records are created in 'Voorraad_uit' when an incoming stock item is partly or completely shipped.  This second table contains mainly the outgoing amount and a unique outgoing delivery ID.

      As a consequence, one record in table 'Voorraad_in' (= incoming stock) can have one ore more related records in 'Voorraad_uit' (=outgoing stock).
      I want to make a subsummary report showing the total amount of incoming and outgoing units per product(name) by using the following layout structure:

      I tried two scenarios which each give me a part of the desired result.
      when I base the layout on 'Voorraad_in' (=incoming stock): I get the right totals for incoming deliveries I get all the incoming deliveries listed (also those without outgoing delivery) Body part 3 (see above) only shows one row also when there are more than one related outgoing transactions I get the wrong totals for outgoing deliveries (only based on one record) when I base the layout on 'Voorraad_uit' (=outgoing stock): I get the wrong totals for incoming deliveries I don't get all the incoming deliveries listed (only those with outgoing delivery) Body part 3 (see above) shows all the related outgoing transactions I get the right totals for outgoing deliveries Main goal is having the right totals for both incoming and outgoing deliveries..
      My layout is sorted ascending by (in mentioned order) productname, incoming delivery number and outgoing delivery number.
      The totals are calculated by using summary fields.
      I hope I'm on the right track and that the desired result is possible.. your help is much appreciated!
      Thanks in advance for your help.
      Regards,
      Solvax
  • Who Viewed the Topic

×
×
  • Create New...

Important Information

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