Georg, Dave, Et al,
After the discussion on the list regarding what a New RealDatabase
returns from an unintialized database date field, I took a step back
and examined the issue. What I came up with is simple and effective.
I should have seen it immediately but I still thinking Microsoft Jet
database and ADO:
// Determine if the date field is initialized
If Trim(rsTemp.Field("datevar").StringValue) = "0-00-00" Then
rsTemp.Close
Return Nil
Else
tmpDate = rsTemp.Field("datevar").DateValue
rsTemp.Close
Return tmpDate
End If
I hope this helps somebody else.
-Scott.
Webconnected International
Killeen, Texas USA
---- Original Message ----
From: georg_christmann at yahoo dot de
To: realbasic-nug at lists dot realsoftware dot com
Subject: Re: New Real Database bug or feature?
Date: Wed, 30 Mar 2005 22:44:33 +0200
>Hi, Scott
>
>One caveat with the suggested parsedate workaround, at least on the
>Mac
>side:
>
>Play around with that function feeding it garbage strings and you
>will
>find it does not reliably fail (i.e. return false), but sometimes
>the
>underlying toolbox function will attempt an "educated guess":
>
><http://support.realsoftware.com/listarchives/realbasic-nug/2002-08/
>msg00289.html>
>
>Of course, this was a long time ago, but the current behaviour would
>
>indicate that this or a similar mechanism is still being employed.
>Thus, you should always write some sort of validating code before
>feeding a string to the parsedate function.
>
>Maybe things work in a similar way on the Windows OS?
>
>Just to let you know.
>
>Georg
>
>
>Am 30.03.2005 um 18:15 schrieb realbasic at webconnected dot com:
>
>> RealBasic 5.5.5
>> Windows XP
>>
>> When retrieving an un-initialized date from a New Real Database
>> record ala:
>>
>> ===================
>> Dim regdate As New Date
>>
>> // Database already open
>> // Recordset rstemp created with a single record
>> // with date field datevar that has never had
>> // a value stored to it
>>
>> regdate = rsTemp.Field("datevar").DateValue
>>
>> MsgBox regdate.ShortDate
>> ===================
>>
>> When I look at the database table in the IDE or Freak Software's
>fin
>> RealSQL I see "0-00-00"
>>
>> But...
>>
>> The messagebox displays today's date!
>>
>> Bug or Feature?
>>
>> Can anyone dispel my ignorance or suggest a workaround?
>>
>> -Scott.
>>
>> WebConnected International
>> Killeen, Texas USA
>>
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives of this list here:
>> <http://support.realsoftware.com/listarchives/lists.html>
>>
>
>
>_______________________________________________
>Unsubscribe or switch delivery mode:
><http://www.realsoftware.com/support/listmanager/>
>
>Search the archives of this list here:
><http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|