while fetching data from excel sheet i m getting the date format (dd/mm/yyyy) but requirement is to change it to (mm/dd/yyyy) format. please help me with this.
DateTime.ParseExact(yourdatevariable.toString(), “dd/MM/yyyy”, Globalization.CultureInfo.InvariantCulture)
.ToString(“MM/dd/yyyy”)
Use this in an assign activity!
DateTime.ParseExact(here_your_date.ToString(),“dd/MM/yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)
and please add system.globalistaion in imports.
THANK YOU FOR YOUR HELP
Please mark it as solution
I also have the same problem, and it is strange that I use exactly your example: Dates.xaml, but instead of working directly on the string, I read it from excel, convert it to string, trim the hrs, minutes, and seconds, but it comes the following error message:
The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar.
I have imported the system.globalisation.
Anyway I use a tedious method, but work: using .subString to get the year, month, and date, then append them together to form a new string.
You say you’re converting it to string - what variable type is it when you grab it from excel? If it’s already a datetime, then you can just do YourDateVariable.ToString(“MM/dd/yyyy”)
Also, if you could upload the excel sheet with the date that you’re having trouble with that’d make it easier for us to help
Dear Dave,
Very much appreciate and amazed by your prompt response. I attach the file for your reference, and I am quite sure the variable read from excel is converted to string type using .toString, and I can write it by Write Line activity.
Thanks a lot.
Snowman
DateTime - Test.zip (20.9 KB)
Hi Dave,
I take your advice, and I first read the excel data as string, Date1, then convert the sting to a DateTime variable, Date2 = CDate(Date1). Then use your advice Date2.ToString(“yyyy/MM/dd”). It works and is more straight forward.
Thanks
For my case I have to convert all dates in all rows for example row(7) to dd.mm.yyyy. Do I have to assign a new variable?
what if i have a column of date i want to convert from dd/mm/yyyy to yymm?
@Dave @Snowman @Akhil @Thomas78 @Fabricio.camara @junnieset @loginerror
how to convert date in the format “DD-MMM-YY” OR “DD-MMM-YY” TO DD/MM/YYYY ?
example 26 March 21 to 26/03/2021 or 19 Feb 2021 to 19/02/2021
Hi,
new_date = DateTime.ParseExact(string_date.ToString,"DD-MMM-YY", Globalization.CultureInfo.InvariantCulture).ToString("DD/MM/YYYY")
its throwing error … what should be the variable type of new_date string and datetime is not working
new_date should be a datetime variable and string_date should be a string variable.
It looks like there is an error in the ParseExact date format though. Take a look here to see all datetime formats: Custom date and time format strings | Microsoft Learn
26 March 21 would be formatted as “dd MMMM yy” (note the capitalization of M but not d or y, it’s important!) and 19 Feb 2021 would be “dd MMM yyyy”
Hi
How to convert “Monday, February 20th” this date format into dd/mm/yyyy this year.
please help me out
tx
AB
Hi @absithyd,
Check this
DateTime.ParseExact(("Monday, February 20th").ToString.Replace("th",Nothing),"dddd, MMMM dd",system.Globalization.CultureInfo.InvariantCulture)
Thanks,