Question

Datetime package - Assign action

  • 12 September 2022
  • 7 replies
  • 47 views

Badge +5

Hi,

 

I am using the Assign action from Datetime package as below :

 

imageEven if I am selecting the "Prebuilt formats" radio button & selecting any prebuilt format from the drop down list, still it is giving me below error:

 

imageI have tried different custom formats as well but no luck.

 

Can anyone please help me with this?

 

Thanks in advance for any leads.


7 replies

Badge +5

Yeah, with the above format it worked but why I am not able to give any other format?

Badge +5

Hi @Ashwin A.K​ 

 

Thanks for the answer, but I am asking that is there any set of predefined date formats which can be used only for the Assign action in datetime package?

 

Also, I am trying to use is equal to action of datetime package & its giving me false result eventhough i am matching today's date (12-09-2022) with the $System:Date$

Userlevel 3
Badge +7

Hi @Abhishek Mishra​ ,

 

There are predefined formats which you can see from the dropdown, but the string you pass in has to follow the exact convention which is why people usually go for custom formats.

 

The DateTime: Assign Action is used to convert String to DateTime.

 

As for the If Condition not working as expected, you have to keep in mind that the converted date does not contain the timezone, which is probably why it fails.

 

Try converting the System: Date to the same format and use a String Condition to check if its equal instead.

 

Kind Regards,

Ashwin A.K

Userlevel 3
Badge +7

Hi @Abhishek Mishra​ ,

 

When you convert a string date to DateTime, you have to specify what format its currently in otherwise the program won't be able to parse it.

 

If you want to convert the date to a different format, first convert that string to DateTime then use the DateTime: To String Action and pass in the desired format.

 

imageI hope that clears things up for you?

 

Kind Regards,

Ashwin A.K

Badge +5

Hi @Ashwin A.K​ 

 

yes I thought of the same thing while using system time, so converted it to string and working fine now.

 

So if i am getting some date as a string from excel and i wan to check whether that is equal to system date (in string format) then i can use simple if condition as well, right?

Userlevel 3
Badge +7

Hi @Abhishek Mishra​ ,

 

Since you are trying to convert string to date, the format must match.

Could you please pass in dd-MM-yyyy and see if that works out for you?

 

Kind Regards,

Ashwin A.K

Userlevel 3
Badge +7

Hi @Abhishek Mishra​ ,

 

Yes you can do that.

If the dataset is large, then you could try experimenting with this concept and see if that works out for you.

 

Also, if you've found my answers helpful then I'd appreciate it if you could mark the answer as Best so that others facing similar issues may benefit from it.

 

Kind Regards,

Ashwin A.K

Reply