cancel
Showing results for 
Search instead for 
Did you mean: 

Using the IsDateTime function regardless of locale

bbastien
Level 3

Hello everyone,

 

I am currently trying to make the validation step of a process, in which I need to check that a date obtained through an excel is correctly formated. However, the target format is "dd/mm/yyyy", while my machine's is "mm/dd/yyyy", therefore I want to use the FormatDateTime to turn it to the right format, but when I do, the IsDateTime function gives me a "False", when the original value got a "True". I figured it is likely because of my machine's format, but I wanted to know if there was a way to make the IsDateTime function work despite that issue ?

 

Thank you in advance for your replies ! 

Regards,

bbastien

2 REPLIES 2

steven.boggs
Staff
Staff

The calculation functions FormatDate, FormatDateTime and FormatUTCDateTime all output a Text item and not a Date Item.

The function description advises:

FormatDate(Date,Format)
Gets text representing a local date in a given format.
 e.g. FormatDate("01/02/2003","dd MMM yy")
 results in "01 Feb 03".

If this is stored within a Date field then it will attempt to convert this into a Date item and may result in unexpected results (i.e. IsDateTime returning 'False').

To get around this, when storing the outcome of the FormatDate command, try clicking on the icon "Store Result". This will create the outcome - "Store Result" field - of the correct Field type - e.g., Text Field.

I hope I understood your question here and this helps -- if not, please feel free to clarify.

bbastien
Level 3

This might come as an issue I haven't anticipated yet, as I do not store values as DateTime items, but I believe my issue comes before even storing the values:

I am checking if a text is of a valid datetime format, which I do using the (I believe) appropriate IsDateTime function. However, the problem is that, while it works if the value follows my machine's datetime format, it seems that it won't recognize another format as appropriate. For example, it will return True for "7/17/2024 12:35:32 PM", but not if I try and use another one, for example "17/7/2024 12:35:32" will return False. 

This is a problem, because the FormatDateTime function requires a DateTime (or a text which can be interpreted as a DateTime) value in order to actually format it. 

Therefore, a perhaps more accurate formulation of my question is : Is there a way for me to validate that a text is a DateTime value no matter the local format it may be having, without having to switch my computer (or blueprism's, I am not sure which one is checked internally)'s language or datetime system, as this would render my process unable to treat certain work items should they have a different format than that of the running machine ?

Thank you in advance for your response !