Hello!
I am trying to convert my string to date but i get this error in the image
Hello!
I am trying to convert my string to date but i get this error in the image
Use the below one in the place of StrVariable pass your String variable.
DateTime.ParseExact(StrVariable, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Note - In the place of dd/MM/yyyy you can change the format.
Hope it helps!!
Try this
DateTime = DateTime.ParseExact(dateString, format, System.Globalization.CultureInfo.InvariantCulture)
string dateFormat = “MM/dd/yyyy”;
// Convert string to DateTime using DateTime.ParseExact
DateTime dateValue = DateTime.ParseExact(dateString, dateFormat, CultureInfo.InvariantCulture);
According to our System Date Time format is MM/dd/yyyy. So It will give you an error.
DateTime.ParseExact(StrVariable, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
(Datatype: System.DateTime)
Regards,
You are storing the Datetime in a Variable right,
Then Change the variable type to System.DateTime
Hope you understand!!
Variable type as System.DateTime
try this:
DateTime.ParseExact(StrVariable, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
In place of dd/MM/yyyy
give the time format that you are getting.
The output variable type is DateTime
I change for this and return to first error…
DataVencimento has a newline at the end, that’s why the end single quote is on the next line of the Output.
how do i solve this?
Get rid of the newline at the end of the string.
DataVencimento.Replace(VbCrLf,“”)
Now I need to know the name of the month, do you know any way I can do it?
In Syntex in the place of dd/MM/yyyy
MM give MMM to get like Jan,Feb
If you give MMMM to get like January, February.
Hope it helps!!
When I change from dd/MM/yyyy to “MMMM” it gives me this error:
Assign: String ‘07/17/2023’ was not recognized as a valid DateTime.
But with dd/MM/yyyy it works…
Make your .ToString…
.ToString(“MMMM”)
Thats work!! Tks
And to change to other language?
i try this
DateTime.ParseExact(newlineClean, “dd/MM/yyyy”, System.Globalization.CultureInfo.CreateSpecificCulture(“pt-BR”)).ToString(“MMMM”)
but not work