0

In the Source Schema I have the Date in xs: date Time Datatype in the Destination Schema I have Date in String Datatype. When I map directly I get the output as "2013-10-21T00:00:00". But I want it "2013-10-21" in output.

I tried using the scripting but nothing worked like,

public String ConvertEndDate(string param1)
{
return DateTime.Parse(param1).ToString("yyyy-MM-dd");
}

public string convertHireDate(string Date1)
{
return DateTime.ParseExact(Date1, "YYYY-MM-DDThh:mm:ss", null).ToString("yyyy-MM-dd");
}

Can anybody help me to deal with this. Thanks in advance.

trx
  • 2,077
  • 9
  • 48
  • 97
  • What is the issue ? Do you get exception ? do you do this? ConvertEndDate("2013-10-21T00:00:00") and convertHireDate("2013-10-21T00:00:00"); ?? – Pavenhimself Sep 17 '14 at 13:45
  • I am getting the date "10/21/2013" as output but I want it to be in "2013-10-21" – trx Sep 17 '14 at 14:02

1 Answers1

2

You would change INVALID DATE to something appropriate for your application.

 public string FormatDate(string inputDate)
    {
        System.DateTime strDate;
        if (System.DateTime.TryParseExact(inputDate, "yyyy-MM-ddTHH:mm:ss", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out strDate))
        {
            return strDate.ToString("yyyy-MM-dd");
        }
        return "INVALID DATE";
    }
Johns-305
  • 10,908
  • 12
  • 21