Solved Convert Date/Time value to Text (1 Viewer)

ThyTony

New member
Local time
Today, 15:42
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:42
Joined
Sep 21, 2011
Messages
14,217
Test is null on raw field, not formatted version?
 

bob fitz

AWF VIP
Local time
Today, 09:42
Joined
May 23, 2011
Messages
4,726
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"))
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:42
Joined
May 7, 2009
Messages
19,226
StrMeetingDate: iif(IsDate([MeetingDate]), Format([MeetingDate], "dd-mm-yyyy"), "N.A")
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:42
Joined
Feb 19, 2002
Messages
43,196
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

Top Bottom