Greetings,
I am trying to change the date format of a string variable
strdateA= “24/03/2024”
desired Output is Mar-24 i.e in the format of (“MMM-yy”)
Here when I am passing the syntax in the second variable which is also a string type i.e. strNewDate = Datetime.Parse(strdateA).Tostring(“MMM-yy”)
I am getting the above error.
I tried changing the variable type to DateTime but no use even I tried to change the sytnax by convert.datetime(strdateA).tostring(“MMM-yy”)
whats would be the issue here?
Parvathy
(PS Parvathy)
2
Hi @Anirudh_Tugawe
Please retype the double quotes ". This should solve
strNewDate = Datetime.ParseExact(strdateA,"dd/MM/yyyy",System.GLobalization.CUltureInfo.InvariantCulture).Tostring("MMM-yy")
Regards
lrtetala
(Lakshman Reddy)
3
Hi @Anirudh_Tugawe
Try this
DateTime.ParseExact(strdateA, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MMM-yy")
Thanks for your fast reply, I changed it according to your comment but no use. it throws the error string that was not recognized as a datetime
Parvathy
(PS Parvathy)
5
Hi @Anirudh_Tugawe
Try this:
strNewDate = Datetime.ParseExact(strdateA,"dd/MM/yyyy",System.GLobalization.CUltureInfo.InvariantCulture).Tostring("MMM-yy")
Regards
Parvathy
(PS Parvathy)
6
Check the below image for better understanding @Anirudh_Tugawe
Regards
lrtetala
(Lakshman Reddy)
7
@Anirudh_Tugawe
DateTime.ParseExact(strdateA, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MMM-yy")
1 Like
@lrtetala @Parvathy
DateTime.ParseExact(strDateA, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MMM-yy”)
I was using “-” instead of “/” in the date format, maybe because of that it was showing me the error.
Thank you Guys you both are correct
lrtetala
(Lakshman Reddy)
9
Yes @Anirudh_Tugawe
that is the issue you are using “-” instead of “/” in the date format
Please close the topic by mark it as solved.
Regards,
Last question can we switch Column A to Column B and vice versa in an excel?
lrtetala
(Lakshman Reddy)
11
Yes @Anirudh_Tugawe
If the format is same in 2 columns you can
yes, it is required to switch the columns just
system
(system)
Closed
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.