Solved Convert Date/Time value to Text

ThyTony

New member
Local time
Today, 09:45
Joined
Feb 14, 2022
Messages
9
I have a Date/Time field which I call MeetingDate. When I do a report based on the query in which there's MeetingDate field, there's some empty values of the field and I want to put text "N.A" in it. In the query I've created a new field which I call "StrMeetingDate" which I converted to string as below:

StrMeetingDate: IIf(IsNull(CStr(Format([MeetingDate],"dd-mm-yyyy"))),"-",CStr(Format([MeetingDate],"dd-mm-yyyy")))

When I run the query, I still got empty value. What's wrong with my condition? Or how can I do it?
Thanks
1645432040334.png
 
Test is null on raw field, not formatted version?
 
Testing for Len()=0 on Format([MeetingDate],"dd-mm-yyyy") seems to work. Something like:

IIf(Len(Format([MeetingDate],"dd-mm-yyyy"))=0,"N/A"Format([MeetingDate],"dd-mm-yyyy"))
 
StrMeetingDate: iif(IsDate([MeetingDate]), Format([MeetingDate], "dd-mm-yyyy"), "N.A")
 
Something to remember --

NEVER, EVER format a date and then try to use it as a date. Dates are NOT strings, they are double precision numbers and strings do not work as dates. So, do your validation and sorting first, then format:)
 

Users who are viewing this thread

Back
Top Bottom