Split date in datarow

Hi all,
i need some support about a value of type datetime, contained in datarow(ex.20/05/2021). I want to extract or the date in string format without slash(20 05 2021) or the single value(20),(05),(2021).
Appreciate your help

Hi @andreus91

To get dateformat withoutslash, you can try below syntax

in an assign activity

str_var = datetime.ParseExact(“20/05/2021”,“dd/MM/yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd MM yyyy”)

If you want to get the values separately use
Split(“20/05/2021”,“/”) and get the result in array.

Thanks,

1 Like

If you can access the DataRow variable in some variable, let say row in an iterative activity like For Each Row, then use the following expression:

DateTime.ParseExact(row(0).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd”) → Returns you day

DateTime.ParseExact(row(0).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”) → Returns you month

DateTime.ParseExact(row(0).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy”) → Returns you year

DateTime.ParseExact(row(0).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd MM yyyy”) → Returns you the date without slashes

Otherwise, you can try splitting the date you are receiving in terms of ‘/’:

String.Split(row(0).ToString,“/”)