More NDT.LocalTime R5 to R6 issues

No question, I just wanted to point this out for anyone doing R5 to R6 migrations.

NotesDateTime.LocalTime seems to have some peculiar differences between R5 and R6.

I’ve seen a few others posted in this forum, but I did not find one that pointed this out:

If you have a NotesDateTime object, set to a null value (for instance, using .SetAnyDate() and .SetAnyTime()), the LocalTime property will return a different DATA TYPE in R5 than in R6.

For Instance:

Dim NDT as NotesDateTime

Set NDT = New NotesDateTime(“”)

Call NDT.SetAnyDate()

Call NDT.SetAnyTime()

Msgbox TYPENAME(NDT.LocalTime)

Will prompt ‘EMPTY’ in R5, but will prompt with ‘STRING’ in R6.

I had an issue today, where one of my old db’s came back to haunt me.

I had been checking the condition of:

If IsEmpty(NDT.LocalTime) Then…

One of the clients that uses this db just upgraded to R6, and was getting strange results.

At the time, I couldn’t use NDT.LocalTime = “”, because comparing EMPTY to “” returns false. So would IsNull().

If you really MUST compare the LocalTime property of a NotesDateTime (though you should find a different way!), and you must do this in a mixed environment, I found that you can use:

If(Format$(NDT.LocalTime, “mm/dd/yyyy”) = “”) then…

Subject: More NDT.LocalTime R5 to R6 issues

Thanks for the tip.

When I first read your post, I thought you had to have got it wrong, and had to go ‘play’ in R5 to prove it (I’m mostly using 6 now). But I found out you are correct! I remember testing for empty dates has always been a problem.

The property NDT.LocalTime is supposed to return a string (according to both the R5 and nd6 Help files). So to me the nd6 way is the ‘right’ way - a string property should never return EMPTY, as that applies to variant variables only. When testing, I came up with the following code (after setting the date and time using SetAnyDate and SetAnyTime):

If ndt.localtime = “” Then

Print “ndt.LocalTime equates to an empty string”

Else

Print “ndt.LocalTime does NOT equate to an empty string. It contains the value {” & ndt.localtime & “}”

End If

In R5 the output from this code is:

ndt.LocalTime does NOT equate to an empty string. It contains the value {}

  • to me this is a kind of tautology.

Forms, to my mind, still get it wrong. A Date/Time field with no value returns an empty string in LotusScript, not a variable of type date-time with the value EMPTY which I think is more logical.

At least we are a small step closer to consistency.

Now if we could only convice you Americans that the format mm/dd/yyyy is totally illogical …

I’ve put this on my list of things to look for during migrations.

Subject: RE: More NDT.LocalTime R5 to R6 issues

Forms have nothing to do with it, since forms don’t have values associated with them. What you are working with are NotesItems, which are typed entirely by their content, with TextList as the default type. Field widgets will translate valid, translatable text to the correct data type before sending the value to the NotesItem. That does not include “uninitialized Variant” (EMPTY), since that is just a language construct in LotusScript, not a value as such.

Subject: RE: More NDT.LocalTime R5 to R6 issues

Thanks for the explaination. This is why I browse this forum.

I never thought through the logic of the field to NotesItem conversion (an oversight on my part), and I have never seen anywhere that the default type for a NotesItem is TextList (I’ve just done a quick browse of the designer Help and couldn’t see it although of course I could have missed it entirely). :wink:

It makes more sense now.