Hi, I have stored date in dd-MMM-yyyy but it’s in string type var, I want to store it into DateTime format. I need the same format.
Convert.ToDateTime(strDate).ToString(“dd-MMM-yyyy HH:mm:ss”)
Please try this one
@Jan_Brian_Despi No bro, if you see I need the same result in 3rd as I got in second. I don’t need time I need only date in same format. If you see in 2nd It’s in string type and in 3rd It’s in DateTime type format is changed.
Check whether this will work for you
Convert.ToDateTime(strDate).Date
No bro, It’s giving me the diff format see in the yellow highlighted color. I want the same format which is in the 2nd line
oh so you need the same format in the DateTime type… hmm… I don’t think that is possible. What I know is when we want to have a specific format, we have it as string…
Let me check…
Btw, may I know why exactly you need to have that format in the DateTime type? Does it make any difference?
Bro, if I use in a database query will it take???
Yes. I think it will take it
@balkishan DateTime is a Struct in System namespace. It does not have a format. You can represent it in many string formats.
Yes… it will take it… no problem
Until it is in the proper DateTime datatype format, it will work just fine in the databases too…
Hey
Here is a detailed article on that