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


Groups > comp.databases.filemaker > #2470

Re: Problem With Dates in a Script

From Helpful Harry <HelpfulHarry@BusyWorking.com>
Newsgroups comp.databases.filemaker
Subject Re: Problem With Dates in a Script
Date 2015-11-04 18:37 +1300
Organization Aioe.org NNTP Server
Message-ID <041120151837053144%HelpfulHarry@BusyWorking.com> (permalink)
References <1mdacbh.13bn8z3s523f7N%csampson@inetworld.net> <1mdb3n0.clubbf16ua01rN%clkaufmann@gmx.ch> <041120150857094318%HelpfulHarry@BusyWorking.com> <1mdc0d8.1vu8k8uw88oqgN%clkaufmann@gmx.ch> <1mdbv1y.yhiv3h1amyb43N%csampson@inetworld.net>

Show all headers | View raw


In article <1mdbv1y.yhiv3h1amyb43N%csampson@inetworld.net>, Charles H.
Sampson <csampson@inetworld.net> wrote:
> Christoph Kaufmann <clkaufmann@gmx.ch> wrote:
> > Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:
> > 
> > > If the GetAsDate function doesn't work, you'll have to do the
> > > conversion quasi-manually within the script by parsing the text-date
> > > using the "/" character as the delimiter for each part.
> > 
> > I suggest converting the date to its number format when defining the
> > script parameter:
> > 
> > GetAsNumber ( YourDateField )
> 
> I don't follow here. As I read the description of GetAsNumber,
> 
>      GetAsNumber ("1/2/2016")
> 
> would return the number value 122016. Then, if that value is used as a
> script parameter, it would be implicitly converted to text ("122016").
> Then what should I do?

Working with dates and text dates can cause peculiar things to happen. 

I'd just use the "/" character as the delimiter and parse out the
various parts of the text date. That way you know you've got what you
should have, rather than what automated functions *think* you should
have ... of course the data entry of the text date does have to be very
strict (always a "/", so no dates entered as "7.3.2015").

The Day* is everything up to, but not including, the first "/".
i.e.
     TextDate_Day = Left(TDate; Position(TDate; "/"; 1; 1) - 1)

The Month* is the characters between the first "/" and the second "/"
(start after the first "/" and take the number of characters that is
all the characters minus everything up to and including the first "/"
and minus the five characters for the second "/" and four digit year).
i.e.
     TextDate_Month =  Middle(TDate; Position(TDate; "/"; 1; 1) + 1;
                     Length(TDate) - Position(TDate; "/"; 1; 1) - 5))

The Year is simply the last four digits (assuming the year is always
entered as four digits).
i.e.
     TextDate_Year = Right(TDate; 4)



* You will need to swap the calculations for Day and Month if 
  you're using backwards American dates (MM/DD/YYYY). 



To make it more efficient you could store the position of the first "/"
(Position(TDate; "/"; 1; 1)) in a variable so it is only calculated
once instead of three times.

Helpful Harry  :o)

Back to comp.databases.filemaker | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Problem With Dates in a Script csampson@inetworld.net (Charles H. Sampson) - 2015-11-03 01:05 -0800
  Re: Problem With Dates in a Script clkaufmann@gmx.ch (Christoph Kaufmann) - 2015-11-03 10:26 +0100
    Re: Problem With Dates in a Script Helpful Harry <HelpfulHarry@BusyWorking.com> - 2015-11-04 08:57 +1300
      Re: Problem With Dates in a Script clkaufmann@gmx.ch (Christoph Kaufmann) - 2015-11-03 22:15 +0100
        Re: Problem With Dates in a Script csampson@inetworld.net (Charles H. Sampson) - 2015-11-03 20:23 -0800
          Re: Problem With Dates in a Script Helpful Harry <HelpfulHarry@BusyWorking.com> - 2015-11-04 18:37 +1300
    Re: Problem With Dates in a Script csampson@inetworld.net (Charles H. Sampson) - 2015-11-03 18:58 -0800
  Re: Problem With Dates in a Script (Solved) csampson@inetworld.net (Charles H. Sampson) - 2015-11-04 01:23 -0800

csiph-web