Convert JSON datetime 2017-03-19T23: 54: 46 to 3/19/2017 11:54:46 PM

How to do this in an SSIS script C#script . Currently, datetime is a row from a column . I'm trying to doJSON

DateTime convertedDate = DateTime.Parse(dateString);

but the error says it is CreationTimenot in the current context. I tried inside all sections like

public override void Input0_ProcessInputRow(Input0Buffer Row)

AND

public override void PostExecute()

but still get the same error.

+4
source share
1 answer

Try using DateTime.ParseExact()Function

CultureInfo provider = CultureInfo.InvariantCulture;
DateTime convertedDate = DateTime.ParseExact(dateString,"yyyy-MM-ddTHH:mm:ss",provider);

If you need to return it as a String with the following format MM/dd/yyyy hh:mm:ss tt, you can use the functionToString()

String strDate = convertedDate.ToString("MM/dd/yyyy hh:mm:ss tt");

Link

+1
source

Source: https://habr.com/ru/post/1692003/


All Articles