Format Issue

Hi all,I am trying to convert the following date 20000822 to the following format using this code:

Forall thing2 In doc.DelDate

thing2 = Format(Cstr(thing2), “yyyy/mm/dd”)

End Forall

And keep getting the following “9999/12/31”

DelDate is a number field.

What am I doing wrong.

Thank you,

-vadim

Subject: RE: Format Issue

I am trying to convert the following date 20000822 to the following format using this code:

Forall thing2 In doc.DelDate

thing2 = Format(Cstr(thing2), “yyyy/mm/dd”)

End Forall

DelDate is a number field.

Dim varDateArr As Variant

Dim strDate As String

varDateArr = doc.DelDate

forall x in varDateArr

strDate = cstr(x)

x = left$(strDate, 4) + “/” + mid$(strDate, 5, 2) + “/” + right$(strDate, 2)

end forall

doc.DelDate = varDateArr

Except, of course, that you said this is a number field and now you are assigning it a text value. Which you can do, but it may cause an identity crisis.

Another consideration: It’s a bad idea to store dates in text form, as I have explained elsewhere in these forums. Let your dates be dates, and your figs be figs.

In which case you might write:

Set x = New NotesDateTime(Datenumber(Cint(left$(strDate, 4)), Cint(mid$(strDate, 5, 2)), Cint(right$(strDate, 2))))

Subject: You do not format a String, your format a date or number so…

thing2 = Format(thing2, “yyyy/mm/dd”) will do just fine.

Subject: Format Issue

  • Notes uses “days since a fixed time” to represent a date, but I don’t recall what that fixed time is, and it’s not readily apparent doing a full-text search of the help database. I think it’s January 1, 1899. (shrug) It’s not critical.- What is critical is that the number 20000822 does not mean August 22, 2000, it means “twenty million eight hundred and twenty two days from the fixed time.” This is how Notes will interpret it. If you want August 22, 2000, the best course of action would be convert it yourself by using substrings:

  • theDate=Left$(thing2, 4)+“/”+Mid$(thing2, 6, 2)+“/”+Right$(thing2, 2)

  • If this isn’t acceptable, the only other course of action would be to figure out what this “base date” is, and convert your number accordingly, before using Format$ on it.

  • Hope this helps…