Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.filemaker > #2479 > unrolled thread

Date Comparison Again

Started bycsampson@inetworld.net (Charles H. Sampson)
First post2015-11-07 00:44 -0800
Last post2015-11-08 12:40 +1300
Articles 4 — 4 participants

Back to article view | Back to comp.databases.filemaker


Contents

  Date Comparison Again csampson@inetworld.net (Charles H. Sampson) - 2015-11-07 00:44 -0800
    Re: Date Comparison Again Martin Τrautmann <t-usenet@gmx.net> - 2015-11-07 09:14 +0000
    Re: Date Comparison Again Howard Schlossberg <howard@nospam.fmprosolutions.com> - 2015-11-07 13:21 -0800
      Re: Date Comparison Again Helpful Harry <HelpfulHarry@BusyWorking.com> - 2015-11-08 12:40 +1300

#2479 — Date Comparison Again

Fromcsampson@inetworld.net (Charles H. Sampson)
Date2015-11-07 00:44 -0800
SubjectDate Comparison Again
Message-ID<1mdhq3t.mfhgwyznp5slN%csampson@inetworld.net>
I'm having another problem with comparing dates. My previous problem was
pilot error. I had two consecutive spaces in a local variable name.
That's not a problem here; all spaces in all names have been removed.

My script has one parameter: a date that is going to be used in the
comparisons. Since it is a parameter, it is a string. However, there are
implicit conversions between types that are not clear to me. It most
cases, treating a string that's in the form of a date as a date seems to
work.

I start out the script with the following:

     Set Variable [$StartupDate; Value:Get(ScriptParameter)]
     Set Variable [$ThisDay; Value:Day ($StartupDate)]
     Set Variable [$ThisMonth; Value:Month ($StartupDate)]
     Set Variable [$ThisYear; Value:Year ($StartupDate)]

Subsequent custom dialogs indicate that these four values are what I
expect. Comparisons of this date to other dates don't work. (I'll supply
more detail if needed.)

Here's the new piece of information. If I follow the first Set Variable
above (Get(ScriptParameter)) with

     Set Variable [$StartupDate; Value:Date (Month ($StartupDate);
       Day ($StartupDate); Year ($StartupDate))]

the script now works. Probem solved? Maybe so, but I'd like to know why
implicit type conversions appear to work sometimes and don't in others.
What I mean by "appear to work sometimes" is exemplified by the other
three Set Variable statements above. In those statements, the Day,
Month, and Year functions take the string form of $StartupDate, parse
it, and extract the expected values. These values are used in the
subsequent code without problem.

As before, any syntax errors in the above code fragments are caused by
my typing. The actual code is created by ScriptMaker and is free of
syntax errors. Also, I'm using FileMaker Pro 8.0v3.

Charlie
-- 
Nobody in this country got rich on his own.  You built a factory--good.
But you moved your goods on roads we all paid for.  You hired workers we
all paid to educate. So keep a big hunk of the money from your factory.
But take a hunk and pay it forward.  Elizabeth Warren (paraphrased)

[toc] | [next] | [standalone]


#2480

FromMartin Τrautmann <t-usenet@gmx.net>
Date2015-11-07 09:14 +0000
Message-ID<slrnn3rg72.1t3.t-usenet@ID-685.user.individual.de>
In reply to#2479
On Sat, 7 Nov 2015 00:44:44 -0800, Charles H. Sampson wrote:
>  I start out the script with the following:
> 
>       Set Variable [$StartupDate; Value:Get(ScriptParameter)]
>       Set Variable [$ThisDay; Value:Day ($StartupDate)]
>       Set Variable [$ThisMonth; Value:Month ($StartupDate)]
>       Set Variable [$ThisYear; Value:Year ($StartupDate)]
> 
>  Subsequent custom dialogs indicate that these four values are what I
>  expect. Comparisons of this date to other dates don't work. (I'll supply
>  more detail if needed.)

show the comparison itself - this most important fact does miss here.

>  Here's the new piece of information. If I follow the first Set Variable
>  above (Get(ScriptParameter)) with
> 
>       Set Variable [$StartupDate; Value:Date (Month ($StartupDate);
>         Day ($StartupDate); Year ($StartupDate))]
> 
>  the script now works. Probem solved? 

How is the ScriptParameter defined or passed over?

There could be many reasons - e.g. ScriptParameter ist derived from a
date value. Date then could be passed in four different ways - as an
integer value representing the date or as a textstring, both times with
or without a type declaration of what the value is.

For the second one, you make sure that StartupDate should be of type
date. However, whether this info is kept, that may or may not happen.

Usually, Dates are stored internally as integer numbers. I did not check
what the latest version does take

... a small check reveals that date 1 is 0001-01-01.

This info may be used either for integer operations (such as date+7),
for integer comparisons (2015-08-01 is more that 2015-07-31), but on
some occasions as text to ("date: "&datefield). 

There seem to be some heuristics how and when the date is converted
between an integer and text formatting, but better not to rely on those.

Keep in mind that date in fact is a number, and that using date as text
may be conflicting by local system setup (I prefer the ISO date
formatting as shown above) and different languages or FMP versions.

- Martin

[toc] | [prev] | [next] | [standalone]


#2481

FromHoward Schlossberg <howard@nospam.fmprosolutions.com>
Date2015-11-07 13:21 -0800
Message-ID<n1lpte$sos$4@news.motzarella.org>
In reply to#2479
On 11/7/2015 12:44 AM, Charles H. Sampson wrote:
> I start out the script with the following:
>
>       Set Variable [$StartupDate; Value:Get(ScriptParameter)]
>       Set Variable [$ThisDay; Value:Day ($StartupDate)]
>       Set Variable [$ThisMonth; Value:Month ($StartupDate)]
>       Set Variable [$ThisYear; Value:Year ($StartupDate)]
>
> Subsequent custom dialogs indicate that these four values are what I
> expect. Comparisons of this date to other dates don't work. (I'll supply
> more detail if needed.)
>
> Here's the new piece of information. If I follow the first Set Variable
> above (Get(ScriptParameter)) with
>
>       Set Variable [$StartupDate; Value:Date (Month ($StartupDate);
>         Day ($StartupDate); Year ($StartupDate))]
>
> the script now works. Probem solved? Maybe so, but I'd like to know why
> implicit type conversions appear to work sometimes and don't in others.

My guess is that the day, month and year functions tell FileMaker that 
the input is to be treated as a date, so that any text input (which is 
ALL a script parameter is) is first converted to a date automatically so 
that FM can get the day, month or year.

To fix your problem, just change the first step to:

Set Variable [ $StartupDate; Value: GetAsDate( get(scriptParameter) ) ]

Howard

[toc] | [prev] | [next] | [standalone]


#2482

FromHelpful Harry <HelpfulHarry@BusyWorking.com>
Date2015-11-08 12:40 +1300
Message-ID<081120151240387871%HelpfulHarry@BusyWorking.com>
In reply to#2481
In article <n1lpte$sos$4@news.motzarella.org>, Howard Schlossberg
<howard@nospam.fmprosolutions.com> wrote:
> On 11/7/2015 12:44 AM, Charles H. Sampson wrote:
> > 
> > I start out the script with the following:
> >
> >       Set Variable [$StartupDate; Value:Get(ScriptParameter)]
> >       Set Variable [$ThisDay; Value:Day ($StartupDate)]
> >       Set Variable [$ThisMonth; Value:Month ($StartupDate)]
> >       Set Variable [$ThisYear; Value:Year ($StartupDate)]
> >
> > Subsequent custom dialogs indicate that these four values are what I
> > expect. Comparisons of this date to other dates don't work. (I'll supply
> > more detail if needed.)
> >
> > Here's the new piece of information. If I follow the first Set Variable
> > above (Get(ScriptParameter)) with
> >
> >       Set Variable [$StartupDate; Value:Date (Month ($StartupDate);
> >         Day ($StartupDate); Year ($StartupDate))]
> >
> > the script now works. Probem solved? Maybe so, but I'd like to know why
> > implicit type conversions appear to work sometimes and don't in others.
> 
> My guess is that the day, month and year functions tell FileMaker that 
> the input is to be treated as a date, so that any text input (which is 
> ALL a script parameter is) is first converted to a date automatically so 
> that FM can get the day, month or year.
> 
> To fix your problem, just change the first step to:
> 
> Set Variable [ $StartupDate; Value: GetAsDate( get(scriptParameter) ) ]

Unlike many programming languages, FileMaker is pretty forgiving about
mixing data types ... *BUT* dates and times do seem to be more picky
than numbers and text. Possibly that's at least partly due to the
various different formatting dates can have (i.e. DD/MM/YY or
MM/DD/YYYY or DD MMMMM, YYYY, or DD.MM.YYYY, etc.)

Helpful Harry  :o)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.filemaker


csiph-web