-1

Basically I have been tasked with editing the company database for dates field known as 'CreateDt'.

However the dates with in this field are stored in numerous amounts of formats which need to be converted into one, some examples are shown below;

29/01/2001 08:51:56
29/01/2001 12:09:07
05/06/2002
30/01/2001 11:48:53
31/01/2001 09:30:12
11/12/2014
12 December 2014
15/12/2014
15/12/2014
15 December 2014
15/12/2014

I have previously tried SQL server to convert however I have encountered problems when day and month values are less than 13 and dates are changing from for example

11/12/2014
to
21/11/2014

Would anyone have C# code which would enable me to format all dates accordingly

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
UCDA2919
  • 1
  • 3
  • Are you sure that there are no ambigious dates / formats mixed in there? If you have for example dates in the formats `dd/MM/yyyy` and `MM/dd/yyyy` then this conversion might be very hard or even impossible to do. – bassfader Mar 11 '19 at 13:14

1 Answers1

0

There is no such code because simply put, a computer cannot do, what a human cannot define.

11/12/2014

Can you tell me whether that is "November 12th" or "11th of December"? Probably not and that's not surprising. But neither can a computer.

Your best bet is to gather all formats that you think are applicable. For example for the value above, you need to decide which format is correct and which value you want to get. Then convert all your data with those few formats.

nvoigt
  • 75,013
  • 26
  • 93
  • 142