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.