date-time format wrong!!

Thorsten Hohage thohage at objectmanufactur.com
Tue Dec 11 15:00:25 CST 2007


AFAIR I've already written this to the list when the "issue" popped up  
some months ago, but here we go again...

There are some issues in date handling in REALbasic, so don't blame  
(only) Vaentina for this issue. When you use this

	field("").datevalue

then it's REALbasic style you first cast the retrieved value to this  
<ironic>wonderful</ironic> Variant type and the call a second cast in  
pure RB to get an instance of the RB data class. Everything what could  
go wrong here will go wrong here for sure at one of you clients!


So it's ways better to use the native Valentina methods

	Dim pDataSet As DDODataDictionary
	Dim pCursor As VCursor
	Dim dValue As Date

	dValue = pCursor.DateField(i).GetDate()

OR

	dValue = pCursor.TimeField(i).GetTime()

OR

	dValue = pCursor.DateTimeField(i).GetDateTime()


then you can handle the intance of the RB date class in any way you  
want. I can additional give the advice that if you ever want to store  
these retrieved values in a Dictionary, then you should use the above  
step, too and then do a

	pDataSet.Value("somenamehere") = dValue

this will kept many headaches away from you.


Of course it's the same story when writing the data back to Valentina,  
DON'T USE THE RB STYLE, use the Valentina native


	Dim dummyDate As Date


	myCursor.DateField(i).SetDate(dummyDate)

OR

	myCursor.DateTimeField(i).SetDateTime(dummyDate)

OR

	myCursor.TimeField(i).SetTime(dummyDate)



And for using values from dictionaries it's the same story as  
retrieving, so always use a

	dummyDate = pDataList.Value(fieldName)

to first get a real instance of the RB date class and then put it into  
Valentina.



Two additional remarks:

* the date class is a real class and not a variable "type" like  
Integer or Double. A lot of errors happens, because of a developer  
didn't get the difference

* Don't always trust the RB debugger in the most current versions,  
there are a lot of glitches and especially with instances of the RB  
date class they casted to string before displayed!!!!


HTH


On 2007-12-11, at 19:32, Joseph Morgan wrote:

>
> On Dec 11, 2007, at 9:31 AM, Danny Lewkin wrote:
>
>> It's even worse than that!!
>>
>> A string from RB, stored in the DB through a cursor, is also stored  
>> in the wrong way!!
>> What I mean is, the string in RB is 2007-12-11 14:35 (on debug  
>> level), when I store it in the DB and do a select, it shows as  
>> 11-12-2007 14:35 !!
>>
>> The function NOW() should NOT be influenced by de dateformat on a pc!
>> It should look at the dateformat of the DB, and work with that  
>> setting!
>> Well, in my opinion anyway!
>
>
> I have always had difficulty with this as well. See my notes in  
> Mantis ID 0002831:
>
> jojoSATX Mantis quote:
>> realbasic rejects datevalue as a valid date
>>
>> look at it in the debugger of any correct database and the format  
>> should be (I think):
>> yyyy-mm-dd hh:mm:ss
>>
>> Any attempts to access the following fail:
>> realbasics recordset.field("").datevalue
>> recordset.idxfield("").datevalue
>
> Thanks,
> joseph
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina


regards

Thorsten Hohage
--
objectmanufactur.com - Hamburg,Germany




More information about the Valentina mailing list