Checking whether Date input argument contains a date

Hi,

I have a process that follows different paths depending on whether an input date argument has been given or left blank.

The input argument is of type DateTime but I don’t know how to check successfully if there is a date or not.

I firstly tried dateArg.isnumeric on the date argument but this did not work because if I had a value of 2023-06-30 for example dateArg.isnumeric evaluates to false.

I then tried string.isNullorEmpty(dateArg.tostring(yyyyMMdd)) but this evaluates to false if the date arg is empty and as dateArg is a date not a string you can’t just put it into the isnullorempty

Hi @clark.coleman

Try using the below syntax:

Not IsNothing(dateArg)
  • dateArg is the DateTime argument you want to check.
  • If dateArg contains a value (i.e., it is not null), the condition will evaluate to True, indicating that the DateTime argument has been provided.
  • If dateArg is (null), the condition will evaluate to False, indicating that the DateTime argument has not been provided.

Hope it helps!!

1 Like

Hi,

As DateTime type is structure, we cannot have it blank. The variable always have something datetime as the following.

image

Or we may be able to check if it’s 01/01/0001.

Regards,

1 Like

Hi @clark.coleman

Try this:
Not inputDate.Equals(DateTime.MinValue)

2 Likes

Thanks All,

I did actually also try the IsNothing() approach but this evaluates to false even when no value has been set (as Yoichi suggested).

I’m going to use Supriya’s suggested code (thank you)

Thanks everyone for your suggestions.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.