Skip to main content

I have CSV file where I have a date/time field as “(1/30/2023 1:35:45 PM)”. What I want to do is figure out the Month and Year.

 

I am using the DateTime: Assign to convert the string into a datetime value. However, the only output I get from the bot is an unhelpful error “An exception occurred while parsing the date time”

 

No matter what string we enter, we get the same error. I’m not sure what we’re doing wrong. How have you made this work?

Hi @Alessandro 3854 ,

 

First please check what is the Date format you are getting on the System variable called Date. First assign it to a variable and display it after converting to String. You should follow the same format while assigning the Date from the CSV file and later you can choose you desired format while converting it to string.


Hi Alessandro 3854 ,

 

If you have the Date Time value in string format and while using DateTime: Assign to convert the string into a datetime value, Use the Custom Formats as M/d/y hⓂs a , It will give you the datetime D1 in correct format. 


Then you can use DateTime: To String action and use the variable D1 and the custom format as y or M to get the year and month respectively.

Thanks,

Diksha


Thanks for the help. Unfortunately I could not get it to work. I tried the following using your feedback.

=========

Example #1:
Date Time: 1/30/2023 1:35:45 PM
Custom Format: M/d/y hⓂs a

 

Example #2
Date Time: 1/30/2023
Custom Format: M/d/y

Example #3
Date Time: 1/30/2023
Custom Format: MM/dd/yyyy

 


Hi Alessandro 3854

Can you share more details about the issue.

I am using similar things and its working for me fine.

 

Thanks,

Diksha


This is odd. Tried it again and it worked. No change from my side.

I believe the steps outlined were correct, so I will assume this was an issue with the environment.


I have CSV file where I have a date/time field as “(1/30/2023 1:35:45 PM)”. What I want to do is figure out the Month and Year

How to do this Conversion...i tried with above steps mentioned but the error remains the same 
dateTime' expecting 'ZonedDateTime' received 'String'


Hi @Prade 1645 ,

My solution was
1. Remove the first “(“ and last “)”. I used a replace function
2. Then use the DateTime:Assign

  • Custom format
  • M/d/yyyy h🇲🇲ss a

Good luck!


Reply