cancel
Showing results for 
Search instead for 
Did you mean: 

Text getting identified as DateTime instead of Time

chauhannaman98
Level 3
I have a String(Text) which is formatted as Time but when I evaluate the expression, the text gets identified as DateTime. As no date is mentioned in the text, the present date(Today()) is added to it automatically.

17987.png
17988.png
For e.g. Text 07:04:12 will get converted into 04-08-2021 07:04:12 if today is 04-08-2021 instead of Time 07:04:12.

What I really want is:
Taking a Text and deciding whether that string is a Flag, Text, Number, DateTime, etc and storing that string to it's data item after type conversion.

------------------------------
Thanks,
Naman Chauhan
------------------------------
1 BEST ANSWER

Best Answers

Hi Naman,

Since you are dealing with text datatype hence the blue prism is considering it as "DateTime" and is appending today's date. In order to solve the issue, please use conversion ToTime method and then check if it's valid datetime. PFB the snippet for the same.
 
17981.png
Hope it helps

------------------------------
Ritansh Jatwani Senior Consultant
Consultant
EY
Gurgaon
*If you find this post helpful mark it as best answer
------------------------------

View answer in original post

2 REPLIES 2

Hi Naman,

Since you are dealing with text datatype hence the blue prism is considering it as "DateTime" and is appending today's date. In order to solve the issue, please use conversion ToTime method and then check if it's valid datetime. PFB the snippet for the same.
 
17981.png
Hope it helps

------------------------------
Ritansh Jatwani Senior Consultant
Consultant
EY
Gurgaon
*If you find this post helpful mark it as best answer
------------------------------

SrinivasaTammin
Level 3
Hi Naman,

It is bit tricky to Validate whether given string is time or not. However if you can implement same Choice logic inside a Code stage it will be very easy for you to find it out.

Example C# Code for validating and storing it to respective data type

TimeSpan.TryParse(input, out timeOutput)   // For Time and TimeSpan parsing
int.TryParse(input, out intOutput) // For number
DateTime.TryParse(input, out dateTimeOutput) // For DateTime
bool.TryParse(input, out flagOutput) // For Flag

Above code snippet will returns true if the input value is valid time/number/datetime/flag and stores time value to respective data item.

Please do let me know if you have any questions.

------------------------------
Srinivasa Tammineni
------------------------------