Hello,
Is it possible in workflow to check if a string is a valid datetime value?
Thanks,
Julie
Hello,
Is it possible in workflow to check if a string is a valid datetime value?
Thanks,
Julie
Also, I'm seeing that when the Date Token Calculator and Delay activities encounter an invalid DateTime, they do not error; but just give a warning. I would really like them to error and not continue if we somehow have an invalid datetime. Is it possible to detect a warning from the previous activity in workflow?
Thanks,
Julie
Do you actually need the time from the datetime or do you just need the date?
I have had issues bringing over date and time from SQL queries. When I have issues, I take the values and put them in a new token. On the token I make sure to open the Token Tags and check whichever value (Date, Time, or DateTime) I am trying to get.
Then I just just the new token in whatever activity I need the date and/or time.
I'm trying to find a way to validate a string with a datetime in it since Delay and Date Token Calculator activities don't validate and will let the workflow keep going with bogus values. Putting them into a token with a Date Time tag doesn't help raise any errors... it just puts the bogus value in and keeps going. :-0
Are you looking for a specific range? Maybe you could give a little insight as to what values you are getting that are not good values.
Let's say I have a token named BogusDateTime with a value of "2019-03-21 8:00AM 8:00AM" (note, I intentially added an extra 8:00AM to it). I just want a way in workflow to determine if that is a valid datetime value. Not looking for a range, etc. I just simply want to know if it is valid. I tried applying datetime formatting to it into a different token; and that also raised no errors (or even warnings).
Thanks,
Julie
Where is the input coming from? Will it always be the same format? In your example you have year month day, will it always be that? Or could it also be month day year?
Regardless of where it comes from or its current format, I just want to simply take a string and determine if it is a valid date. If you are familiar with SQL Server, you know there is an isdate() function that accomplishes this. I know there is not an "isdate()" function in workflow but was hoping there is some way to achieve it. I can do the following in c#, so perhaps the answer is to just make an SDK call.
protected bool CheckDate(String date)
{
try
{
DateTime dt = DateTime.Parse(date);
return true;
}
catch
{
return false;
}
}