Checking to see if date Field has no value

I want to check a Date Field with an if statement ascertain if it has a value or not.

If it does not have a value I want to put today’s date in. If it has a value I want to make it no value or blank.

I can easily do this to a text field but having trouble with a date field.

SAMPLE CODE

;Togggles «Travel Flag» field between Today’s date and as a cleared field or blank.
Field “Travel Flag”
If «Travel Flag»=""
;then
«Travel Flag»=Today()
;
Else
If «Travel Flag»=""
Endif

SUMMARY

It seems the if statement does not like or recognize if the date field is blank.

Not a show stopper but how do you check to see if a date field is blank?

Thanks

George

This seems to work:

field «Travel Flags» 
«Travel Flags»=?(datestr(«»)="",today(),"")

The problem is that “” means empty text, while date fields contain numbers. In addition to Gary’s suggestion, you could use

if «Travel Flag»=0

or

if sizeof("Travel Flag") = 0

The sizeof function tells you how many bytes of memory are used for that value.

If it is a date field, the value is numeric. «Travel Flag»=?(«Travel Flag»=0,today(),0) works.

Thanks Gentlemen for your clear and lucid explanation and solution.

Much oblidged as usual.

George

The sizeof( function is intended for this purpose, though in most cases simply checking for zero would be sufficient.

Thanks Jim.