[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Odd Error: Month must be between 1 and 12



David
I was of the opinion that the &invoicedate was not null and must contain a
value.
To be sure that invoice.invoicedate was null I had inserted a null value for
this field into the particular record.

It seemed odd.
Even moving &invoicedate to a local variable ($invoiceDate) terminated the
routine and the same error message was displayed.

Before I left yesterday evening I had a work around:
   On selecting invoice.invoicedate convert it to a char (&invoiceDateChr)

Then when invoicedate is NULL then
    isnull(&invoiceDateChr) returns the expected value of 1

My interpretation is that on selecting a date into:
    &dateRetrunedFromDB   = date
then if the date selected is null &dateRetrunedFromDB does not contain NULL
since it has the date formatting chars (mm : ss).

I have not yet been able to confirm this since
    move &invoicedate to $invoiceDate
also causes the routine to terminate and give the error.

I will try some other ways to see what &dateValue ( = date) contains when a
null date is selected into &dateValue.

I accept you point regarding the determination of the length to see if the
value is null/not null.

I have tried:
    let #length = length(&invoicedate)
    show 'invoicenum: ' &invoicenum ' - length: ' #length
This falls over with the same error - Month must be between 1 and 12.

I take your point regarding the determination of the length of &invoicedate.
If the number of formatting chars which &invoicedate contains when invoicedate
is null is less than the whole invoicedate string when invoicedate is not null
then it should be possible to distinguish between null and none null dates.

I have tried your suggestion which looks fine.
However, it falls over when SQR tries to parse length(&invoicedate).
The routine terminates; the same error is displayed.

The only workaround that I have is to determine and trap a null date is to
convert the date selected into a char.

Many thanks.

Trust that all is well...

Andrew


___________________________________
Quoting D E <wirebird1@HOTMAIL.COM>:

> Andrew,
>
> I would think that invoicedate isn't null.  The field must contain a
> space
> or similar character.  Perhaps you could use length() to determine your
> if
> statement:
>
> If length(&invoicedate) < 2 (or 3 or 4 whatever is appropriate)
>           show 'invoicenum: ' &invoicenum ' is NULL'
>        else
>           show 'invoicenum: ' &invoicenum ' - Invoicedate: '
> End-If
>
> David
>
>
> >From: Andrew Rivers <andrew.rivers@CWCOM.NET>
> >Reply-To: sqr-users@list.iex.net
> >To: SQR-USERS@list.iex.net
> >Subject: Odd Error:  Month must be between 1 and 12
> >Date: Thu, 24 Jan 2002 15:21:52 +0000
> >
> >Hi
> >I get the error:
> >Error on line 1377:
> >    (SQR 1925) Month must be between 1 and 12.
> >
> >Line 1377 is as follows (all on one line):
> >     show 'invoicenum: ' &invoicenum ' - Invoicedate: '  &invoiceDate
> >
> >The problem is a NULL value for &invoiceDate in the database.
> >      select invoicenum, invoicedate from invoice
> >             where invoicenum = '1052' and invoicedate is null;
> >This returns:
> >      INVOICENUM     INVOICEDATE
> >      ========== ====================
> >      1052
> >
> >      1 ROW SELECTED
> >showing that invoicenum = '1052' is NULL.
> >
> >However, if the following code is run:
> >       if  isnull( &invoiceDate )
> >          show 'invoicenum: ' &invoicenum ' is NULL'
> >       else
> >          show 'invoicenum: ' &invoicenum ' - Invoicedate: '
> &invoiceDate
> >       end-if
> >
> >the else statement is executed for invoicenum = '1052' and the
> program
> >terminates at:
> >       invoicenum: 1052 - Invoicedate:
> >
> >Other fields including date fields do not give problems.
> >
> >If anyone has any suggestion as to the problem, I would be most
> grateful.
> >
> >Andrew
>
>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
> http://explorer.msn.com/intl.asp.
>