Hola , favor su orientacion, tengo la version nueva de UIPATH y al intentar hacer un cambio de fecha a una variable “Mivariable” ( de tipo String) la cual posee el contenido “11/22/2022 00:00:00” y al aplicar :
DateTime.ParseExact(Mivariable.ToString, “MM-dd-aaaa”, System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString(“yyyy-MM-dd”)
me arroja:
Assign: String ‘11/21/2022’ was not recognized as a valid DateTime.
Alguna idea?
Gokul001
(Gokul Balaji)
November 30, 2022, 2:04pm
2
Try this expression @Fernando_Montano
In the expression you have use aaaa instead of yyyy
DateTime.ParseExact(Mivariable.ToString, “MM-dd-yyyy”, System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString(“yyyy-MM-dd”)
Gokul001
(Gokul Balaji)
November 30, 2022, 2:05pm
3
Hi @Fernando_Montano
How about this expression?
DateTime.ParseExact(Mivariable.ToString, “MM-dd-yyyy hh:mm:ss”, System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString(“yyyy-MM-dd”)
No funciona, arroja mismo Error :
Assign: String ‘11/20/2022 00:00:00’ was not recognized as a valid DateTime.
Gokul001
(Gokul Balaji)
November 30, 2022, 2:08pm
5
Hi @Fernando_Montano
Check out this expression
DateTime.ParseExact("11/20/2022 00:00:00","MM/dd/yyyy hh:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString("yyyy-MM-dd")
Regards
Gokul
cuando ingreso el nombre de la variable me arroja error. Necesito que la expresión sea con “Mivariable”
Gokul001
(Gokul Balaji)
November 30, 2022, 2:15pm
9
Gokul001:
Check out this expression
DateTime.ParseExact("11/20/2022 00:00:00","MM/dd/yyyy hh:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString("yyyy-MM-dd")
Have you tried with this expression ? @Fernando_Montano
ppr
(Peter)
November 30, 2022, 2:19pm
11
do not quote the var name
CDate( Mivariable.ToString).toString("yyyy-MM-dd")
we also recommend to use the debbuging paneld for RnD and Prototyping
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
1 Like
Gokul001
(Gokul Balaji)
November 30, 2022, 2:21pm
12
Hi @Fernando_Montano
Can you print the fechaConsulta
in the log message and share the screenshot?
Try to use .Tostring.trim
DateTime.ParseExact(fechaConsulta.Tostring.Trim,"MM/dd/yyyy hh:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString("yyyy-MM-dd")
1 Like
Funciona!
Muchas gracias @ppr and @Gokul001 !!!
funcionó con :
CDate( Mivariable.ToString).toString(“yyyy-MM-dd”)
y con :
DateTime.ParseExact(fechaConsulta.Tostring.Trim,“MM/dd/yyyy hh:mm:ss”, System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString(“yyyy-MM-dd”)
GRACIAS!
system
(system)
Closed
December 3, 2022, 2:29pm
14
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.