Shane Nicholson

Shane Nicholson

  • 2k
  • 35
  • 461

C# data output format

Nov 17 2020 11:26 AM
Good afternoon all,
 
As always, thank you in advance for your help.
 
I have made a windows form in VS 2019 and have a datetimePicker item. The form data is saved in CSV format and then used in Tableau.
 
The date is stored as ddMMyyyy when saved which is a huge problem. For example, If saved data on 5th Aug 2020, I want it to save it as YYYYMMDD (2020-08-05) but it saves it as 05-08-2020. When I open the saved file, it will show the date as May 08 2020.
 
I simply want the date format to save as YYYY-MM-DD..
  1. private void dateTimePicker1_ValueChanged(object sender, EventArgs e)  
  2. {  
  3. dateTimePicker1.Format = DateTimePickerFormat.Custom;  
  4. dateTimePicker1.CustomFormat = "yyyyMMdd";  
  5. }  
  6. Private void textbox8_Textchanged(object sender, EventArgs e)  
  7. xlworksheet.Cells[1, 1] = textBox1.Text;  
  8. xlworksheet.Cells[1, 2] = dateTimePicker1.Value;

Answers (11)