Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C-Sharp DateTime Culture format for SQL Date-Format

Is there a culture for this date-format?

2022-03-08 23:59:59

Or do I have to do this manualy with .ToString()?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Does it matter if there is a culture which ensures that DateTime.ToString will output this format? What matters is if you want to output a DateTime in a culturally appropriate format or not. If you don’t care about a (given) culture, why do you ask for it?

If all you need is a DateTime as a string in that format, use:

string dtAsString = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading