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


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

Validating an Input Date

Started bycsampson@inetworld.net (Charles H. Sampson)
First post2015-04-11 03:12 -0700
Last post2015-04-12 13:54 +1200
Articles 8 — 4 participants

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


Contents

  Validating an Input Date csampson@inetworld.net (Charles H. Sampson) - 2015-04-11 03:12 -0700
    Re: Validating an Input Date clkaufmann@gmx.ch (Christoph Kaufmann) - 2015-04-11 13:51 +0200
      Re: Validating an Input Date csampson@inetworld.net (Charles H. Sampson) - 2015-04-11 17:43 -0700
        Re: Validating an Input Date Helpful Harry <HelpfulHarry@BusyWorking.com> - 2015-04-12 13:41 +1200
        Re: Validating an Input Date clkaufmann@gmx.ch (Christoph Kaufmann) - 2015-04-12 07:24 +0200
    Re: Validating an Input Date Howard Schlossberg <howard@nospam.fmprosolutions.com> - 2015-04-11 12:12 -0700
      Re: Validating an Input Date csampson@inetworld.net (Charles H. Sampson) - 2015-04-11 17:43 -0700
        Re: Validating an Input Date Helpful Harry <HelpfulHarry@BusyWorking.com> - 2015-04-12 13:54 +1200

#2143 — Validating an Input Date

Fromcsampson@inetworld.net (Charles H. Sampson)
Date2015-04-11 03:12 -0700
SubjectValidating an Input Date
Message-ID<1m2p1sc.onwnbc6d6k1iN%csampson@inetworld.net>
Is there any way in FMP (not advanced) to validate that a text string
contains a correct date? Such things as only digits and slashes and
values that are correct for month, day, and year?

The Help entry for the GetAsDate function contains the following
intriguing note: If the function returns a number instead of a date, go
to the Specify Calculation dialog box and make sure the Calculation
result is date. That sounds like it might be addressing the issue but it
has, for me, a number of problems. To begin with, I don't know how to
find out if a function that is supposed to return a date has returned a
number. In addition, Specify Function Dialog Box doesn't appear to be a
script step, so it's not clear how that's supposed to help even if I
could get by my first problem.

I can certainly write a script that does the job, but I don't like
reinventing the wheel.

The usual disclaimer: I'm working with FMP8.

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]


#2144

Fromclkaufmann@gmx.ch (Christoph Kaufmann)
Date2015-04-11 13:51 +0200
Message-ID<1m2pvlz.h1mf01dmsnwqN%clkaufmann@gmx.ch>
In reply to#2143
Charles H. Sampson <csampson@inetworld.net> wrote:

[FMP 8]
> Is there any way in FMP (not advanced) to validate that a text string
> contains a correct date? Such things as only digits and slashes and
> values that are correct for month, day, and year?

Use a date field to begin with?

If it's just a string outside a date field, you might start with the
filter function:

input =? filter ( input ; "1234567890/." )


-- 
Christoph Kaufmann
http://clk.ch

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


#2147

Fromcsampson@inetworld.net (Charles H. Sampson)
Date2015-04-11 17:43 -0700
Message-ID<1m2q6cg.m2h1xwolhk40N%csampson@inetworld.net>
In reply to#2144
Christoph Kaufmann <clkaufmann@gmx.ch> wrote:

> Charles H. Sampson <csampson@inetworld.net> wrote:
> 
> [FMP 8]
> > Is there any way in FMP (not advanced) to validate that a text string
> > contains a correct date? Such things as only digits and slashes and
> > values that are correct for month, day, and year?
> 
> Use a date field to begin with?

My experiments show that you can input anything into a date field.
Things blow up downstream when you try to use the bad "date".

At present, the only user-friendly processing I'm doing is using TrimAll
with the last argument being 3, which squeezes out all blanks.

> If it's just a string outside a date field, you might start with the
> filter function:
> 
> input =? filter ( input ; "1234567890/." )

Thats a new one to me. What does the "=?" operator do?

Thanks, Christoph.

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] | [prev] | [next] | [standalone]


#2148

FromHelpful Harry <HelpfulHarry@BusyWorking.com>
Date2015-04-12 13:41 +1200
Message-ID<120420151341522081%HelpfulHarry@BusyWorking.com>
In reply to#2147
In article <1m2q6cg.m2h1xwolhk40N%csampson@inetworld.net>, Charles H.
Sampson <csampson@inetworld.net> wrote:
> Christoph Kaufmann <clkaufmann@gmx.ch> wrote:
> > Charles H. Sampson <csampson@inetworld.net> wrote:
> > 
> > [FMP 8]
> > > Is there any way in FMP (not advanced) to validate that a text string
> > > contains a correct date? Such things as only digits and slashes and
> > > values that are correct for month, day, and year?
> > 
> > Use a date field to begin with?
> 
> My experiments show that you can input anything into a date field.
> Things blow up downstream when you try to use the bad "date".
> 
> At present, the only user-friendly processing I'm doing is using TrimAll
> with the last argument being 3, which squeezes out all blanks.
> 
> > If it's just a string outside a date field, you might start with the
> > filter function:
> > 
> > input =? filter ( input ; "1234567890/." )
> 
> Thats a new one to me. What does the "=?" operator do?

"=?" doesn't do anything - it's not a real operator. It's possibly a
typo or a bad conversion of a non-standard ASCII character by a
newsreader / newsserver.

Helpful Harry   :o)

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


#2150

Fromclkaufmann@gmx.ch (Christoph Kaufmann)
Date2015-04-12 07:24 +0200
Message-ID<1m2r8cw.v5bpfi67kmrcN%clkaufmann@gmx.ch>
In reply to#2147
Charles H. Sampson <csampson@inetworld.net> wrote:

> > input =? filter ( input ; "1234567890/." )
> 
> Thats a new one to me. What does the "=?" operator do?

It's no operator, I meant you want to check whether the input is equal
to the filtered input.

Consider using the filter function in auto-enter and use validation for
the following tests. You won't have to test for illegal characters as
these have been stripped already by auto-enter.

-- 
Christoph Kaufmann
http://clk.ch

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


#2145

FromHoward Schlossberg <howard@nospam.fmprosolutions.com>
Date2015-04-11 12:12 -0700
Message-ID<mgbrk3$24s$3@news.motzarella.org>
In reply to#2143
How about:
	isValid( getAsDate( textEntered ) )

Or really, you don't need the isvalid() function.  Since converting an 
invalid value to a date results in "?", you could just test for:
	getAsDate( textEntered ) <> "?"

Howard


On 4/11/2015 3:12 AM, Charles H. Sampson wrote:
> Is there any way in FMP (not advanced) to validate that a text string
> contains a correct date? Such things as only digits and slashes and
> values that are correct for month, day, and year?

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


#2146

Fromcsampson@inetworld.net (Charles H. Sampson)
Date2015-04-11 17:43 -0700
Message-ID<1m2q64x.1udi6ww1arr87qN%csampson@inetworld.net>
In reply to#2145
Howard Schlossberg <howard@nospam.fmprosolutions.com> wrote:

> How about:
>       isValid( getAsDate( textEntered ) )
> 
> Or really, you don't need the isvalid() function.  Since converting an
> invalid value to a date results in "?", you could just test for:
>       getAsDate( textEntered ) <> "?"
> 
> Howard
> 
> 
> On 4/11/2015 3:12 AM, Charles H. Sampson wrote:
> > Is there any way in FMP (not advanced) to validate that a text string
> > contains a correct date? Such things as only digits and slashes and
> > values that are correct for month, day, and year?

Thanks, Howard. I forgot about IsValid lurking there among the logical
functions. This is at least a gross check of the user input, allowing me
to tell him that there's something wrong with his input.

If I want a more specific error indication, such as invalid month number
or month/day mismatch, is it still up to me?

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] | [prev] | [next] | [standalone]


#2149

FromHelpful Harry <HelpfulHarry@BusyWorking.com>
Date2015-04-12 13:54 +1200
Message-ID<120420151354408141%HelpfulHarry@BusyWorking.com>
In reply to#2146
In article <1m2q64x.1udi6ww1arr87qN%csampson@inetworld.net>, Charles H.
Sampson <csampson@inetworld.net> wrote:
> Howard Schlossberg <howard@nospam.fmprosolutions.com> wrote:
> > On 4/11/2015 3:12 AM, Charles H. Sampson wrote:
> > > 
> > > Is there any way in FMP (not advanced) to validate that a text string
> > > contains a correct date? Such things as only digits and slashes and
> > > values that are correct for month, day, and year?
> > 
> > How about:
> >       isValid( getAsDate( textEntered ) )
> > 
> > Or really, you don't need the isvalid() function.  Since converting an
> > invalid value to a date results in "?", you could just test for:
> >       getAsDate( textEntered ) <> "?"
> 
> Thanks, Howard. I forgot about IsValid lurking there among the logical
> functions. This is at least a gross check of the user input, allowing me
> to tell him that there's something wrong with his input.
> 
> If I want a more specific error indication, such as invalid month number
> or month/day mismatch, is it still up to me?

Yep. IsValid will only check if the date (or whatever) is valid, but
doesn't tell you why data is not valid.

If you want a more user-friendly error message, then you will have to
make your own check calculation. You could use IsValid to first check
for a problem, then only go on to the rest if there is an error.

Checking why the date is not valid could be a bit of a problem. You
would have to check that:

    - check there are only valid date characters, including if
      you want to allow textual month names (e.g. "15 Jan 1996")

    - the month is between 1 and 12 (which is easy, unless you want
      to take into account both mm/dd and dd/mm date entry)

    - the day is between 1 and 31, AND within the month's boundary,
      including Leap Days for February (which is more difficult)

    - possibly check the year is valid - whether that's because
      you want to insist on a four digit year or within a set
      period (e.g. 2000 onwards)

Helpful Harry  :o)

[toc] | [prev] | [standalone]


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


csiph-web