Re: Date Validation?

From: Christopher Sawtell <csawtell(at)xtra(dot)co(dot)nz>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>, <dev(at)archonet(dot)com>, josh(at)agliodbs(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Date Validation?
Date: 2001-07-15 03:43:44
Message-ID: 20010715034251.RZSF3874492.mta6-rme.xtra.co.nz@there
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sun, 15 Jul 2001 06:40, Josh Berkus wrote:
> Richard,
>
> > Poked around and had a think and can't come up with anything better
> > than
> > Stephan Szabo's suggestion of hacking PG's built-in function. You'll
> > want
> > to_timestamp() which is called from to_date and it's in
> > src/backend/utils/adt/formatting.c - AFAICT you'll just need to
> > comment out
> > the elog(...) calls and return a null value (or whatever).
>
> Not too likely from me ... I don't do C at all!

'Tis a shame. I could teach you C if you want. Get the lessons from the URL
in the .signature box below.

> I'm one of those
> horrible people who came to SQL & PHP from VB and MS Access rather than
> from a C.S. degree.

Not 'horrible', nobody who has 'seen the light' in any way can be described
as "horrible". That description is reserved for those folks who revel in
their intimacy with darkness. ( How you define "darkness" is over to you )

> Heck, my college degree is in sculpture.

No wonder the aesthetic is so important to you.

> > Failing that, what about writing is_valid_date() in pl-tcl/perl?
> > Don't know
> > anything about tcl, but should be easy enough in perl (cut & paste
> > from a
> > suitable module)
>
> Sounds good. Anybody on the list I can beg (or pay $50) to write it and
> post it to the list? I don't know from perl or tcl either (I do SQL,
> PHP, Java and VB).

Well here is how I deal with the problem.

First you have to turn off the error reporting flag in the php.ini
configuration file. That stops most of the geek-speak rubbish getting out to
the client.

Now, please find attached the .php files I am using in a project.
I feel that the level of geek-speak in the solution is accepable,
but if it isn't to you or your clients, then you could always replace the
error message goming out of PostgreSQL to something more understandable to
the "Common Man / Lay Person" by editing the PostgreSQL source and
re-compiling it. ( not difficult ) Note that I have the database here
configured to the European representation of dates and the wording of the
error messages in the php file reflects this.

Also note that I have forgotton to test for dates being in the past, and that
it would be better if the error message was delivered in a pop-up html page
or a JavaScript alert.

Off the top of my head another untested idea for a solution to the problem is
to do the data verification in JavaScript on the client machine.
There is a JavaScript date.parse() function.

Qualify for the $50 ?

--
Sincerely etc.,

NAME Christopher Sawtell
CELL PHONE 021 257 4451
ICQ UIN 45863470
EMAIL csawtell @ xtra . co . nz
CNOTES ftp://ftp.funet.fi/pub/languages/C/tutorials/sawtell_C.tar.gz

-> Please refrain from using HTML or WORD attachments in e-mails to me <-

Attachment Content-Type Size
record_absence.php text/html 3.0 KB
post_absence.php text/html 14.4 KB

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-07-15 17:21:31 Hey! ORDER BY in VIEWS?
Previous Message Tom Moreau 2001-07-14 22:26:41 Re: Help with SQL statement - Thanks