How to convert to datetime

i have queue item in date format as yyyy-mm-dd(2023-06-06)

and iwant to conevert as dd-MM-yyyy(06-JUN-2023)

but iam getting error

convert.datetime(in_trasactionitem.specificContent(“Date of Service”)).ToString(“dd-MMM-yyyy”)).ToUpper

Hi @T_Y_Raju

Try this

Convert.ToDateTime(in_trasactionitem.specificContent(“Date of Service”).ToString).Date.ToString(“dd-MMM-yyyy”)

I hope it works!!

Hi @T_Y_Raju

Use the below parse expression to change the format

convertedDate = DateTime.ParseExact(yourDateVariable, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yyyy").ToUpper()

Make sure to import the System.Globalization namespace in the Imports panel of your project to use the CultureInfo class.

Hope it helps!!

Try this
formattedDate = If(DateTime.TryParseExact(in_transactionitem.SpecificContent(“Date of Service”).ToString(), “yyyy-MM-dd”, CultureInfo.InvariantCulture, DateTimeStyles.None, dateOfService), dateOfService.ToString(“dd-MMM-yyyy”).ToUpper(), “Invalid Date”)

this is not working.

@T_Y_Raju
Try This one

convertedDate = DateTime.ParseExact(in_trasactionitem.specificContent(“Date of Service”)).ToString, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yyyy").ToUpper()

This also not working

Try this

formattedDate = If(DateTime.TryParseExact(in_transactionitem.SpecificContent(“Date of Service”).ToString(), “M/d/yyyy”, CultureInfo.InvariantCulture, DateTimeStyles.None, dateOfService), dateOfService.ToString(“dd-MMM-yyyy”).ToUpper(), “Invalid Date”)

formattedDate = If(Date.TryParseExact(in_transactionitem.SpecificContent(“Date of Service”).ToString(), “yyyy-MM-dd”, CultureInfo.InvariantCulture, DateTimeStyles.None, dateOfService), dateOfService.ToString(“dd-MMM-yyyy”).ToUpper(), “Invalid Date”)

@T_Y_Raju
Have you created a ConvertedDate variable in string datatype and have you importedthe System.Globalization from the imports.

After doing all this then confirm me

@T_Y_Raju Show queue Item value please

@T_Y_Raju

Try this it is working
DateTime.ParseExact(Datee, “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yyyy”)
image

Hi @T_Y_Raju

DateTime.ParseExact(in_transactionItem.SpecificContent(“Date of Service”).ToString(), “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yyyy”).ToUpper()

Hope it helps!!

yes i have done but still not working

@T_Y_Raju show use queue Item values, pretty sure their is something else

You have your parentheses incorrectly placed. Also, it’s better to use DateTime.ParseExact.

Your input value will be in_transactionitem.SpecificContent(“Date of Service”).ToString

And the expression is…

DateTime.ParseExact(inputValue,format,System.Globalization.CultureInfo.InvariantCulture)

So replace inputValue and format:

DateTime.ParseExact(in_transactionitem.SpecificContent(“Date of Service”).ToString,“yyyy-MM-dd”,System.Globalization.CultureInfo.InvariantCulture)

It’s important to remember that mm is minutes and MM is months. So the above expression gives you the datetime value of your parsed string. If you want to get it back out as a string in a different format just add .ToString(format) on the end:

DateTime.ParseExact(in_transactionitem.SpecificContent(“Date of Service”).ToString,“yyyy-MM-dd”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yyyy”)

MM gives you month number
MMM gives you Jan, Feb, Mar, etc

You can find all these format identifiers here: