7 |
The LA Fox Developer Newsletter
August 1999
Take Care with Dates and Times
Don’t let date and datetime anomalies catch you out.
Visual FoxPro’s array of date and datetime functions normally
work flawlessly
...
but the results are not always what you might
expect. For instance, assigning a “blank” date value to a
variable, like this:
a
=
(0/0/0)
will correctly create a date variable.
But assigning a blank datetime does not produce datetime
variable. Thus:
b
=
(0/0/0 0:00AM)
makes b a date, not a datetime
as you might have thought
Curiously, the following code does create an empty datetime:
b
(/:)
Another unexpected behavior is that this construct: (:} trans-
lates to: 12/30/1899 12:00:00AM
Migration
If you are migrating to VFP from FoxPro 2.x, be aware that the
former is stricter than the latter in its use of date separators. For
example, CTOD(”11298”) is valid in 2.x, regardless of SET
SEPARATOR, but it generates an invalid date in Visual FoxPro.
Year 2000 issues
Visual FoxPre is, for the most part, Year 2000 compliant .. but
care is needed. To demonstrate, let’s look ahead ten years from
the day this article was written:
SET CENTURY ON
dAnrdv = (12/30/07) && ten years from 12/30/97
Now subtract ten years from that date, like this:
? GOMONTH(dAnniv,-120)
If you are using VFP 5 or earlier, the result will be 12/30/1 897
a hundred years earlier than you might have expected.
Thars not a bug. Ihe point is that, when you specify a two-digit
year (in VFP 5 or earlier), the century digits are always taken as
19—even if CENTURY is on, and regardless of the system
date. If, during 1998 and 1999, your users will be entering
forward dates for the next century — contract expiration dates,
for instance — you might want to amend your forms to allow the
full four-digit year to be entered.
By putting the following line of code at the start of your applica-
tion: SET CENTURY TO 20 you ensure that the century digits in a
two-digit year are always 20.
Going further, this line of code:
SET CENTURY TO 19 ROLLOVER 45
(Con't, next column)
Job Opportunites
I’ve got a couple of customers in need of FoxPro expertise. Both
in the valley: Glendale & North Hollywood. I’ve gota ‘world
class’ Foxpro programmer who is out of commisron for about a
month, sick. One of his jobs requires a ‘reservation system’
interlaced with SBTs vfp5o ported package. This is an immedi-
ate need and will serve as a ‘trial balloon’ so to speak.
We normally do the billing, initial analysis, assist with customer
interface and skim some profit off the top though other options
are available.
Another customer is going into full beta on our newly developed
‘Web Wan”; multiple branch offices access business system at
home office via the web. Comprised of home office ‘server’ and
branch ‘client’ applications in VFP5 and 6(?) using ‘Web
connect’ by Rick Strawl. They are coming up with little bugs
that’ll need fixing. Let me know if you have anyone interested
who has the time.
Jim
Shannon at JES Computer Systems
(661) 297-2249, (888) Fox-Pros <mailto:JimShannon@software-
custom.cbm>
Web:
<<http://www.
pacificnet.net/~jimsha>> & <http://
www.software-custom.com>
I am in need of a consultant in the Los Angeles area experi-
enced in Foxpro Visual. The job would be more as an insructor
since we are already familiar with FoxPro for Windows, but need
some customization modifications to a an application from
Satan in order to run their Mail Room Toolkit I have a small bulk
mail business which provides automated mail savings to our
customers. Please contact Patsy Bellah at Bellah Business
Support Services, (310) 840-2957, or e-mail
bellah@caprica.com.
Dates and Times
(Con't from prev. column)
says that the century digits in a two-digit year will be 19 if the
last two digits are 45 or higher, otherwise the century digits will
be 20. In many cases, adding this code will be the only action
you need to take to allow your users to go on entering just the
last two digits of the year.
By the way, these two forms of SET CENTURY were new to
VFP 5.0. They won’t work with earlier versions.
In VFP 6.0, the rollover is established by default, with the pivot
year set to the current year digits plus 50. So, in 1999, a two-
dig it year will be interpreted as being in the range 1950 to
2049.
Then, in each following year, the range will move forward one
year.
(Con't, page 8)
Page 7
|
7 |