Need to fetch only date from the string 2017-05-01T16:46:36.000Z

String : 2017-05-01T16:46:36.000Z

Need to fetch only the date from string i.e, 2017-05-01 and covert to 01-05-2017

thanks,
Chiranjeevi

@Chiru

Use Regular expression to fetch date from given string.

System.Text.RegularExpressions.RegEx.Matches(“String”,“\d{4}-\d{2}-\d{2}”)

@Chiru

To convert the data use below expression.

DateTime.ParseExact(dateString, “yyyy-MM-dd”,
System.Globalization.CultureInfo.InvariantCulture).Tostring(“dd-MM-yyyy”)

Getting compile error

Compiler error(s) encountered processing expression “System.Text.RegularExpressions.RegEx.Matches(created_Date,”\d{4}-\d{2}-\d{2}“)”.
Value of type ‘System.Text.RegularExpressions.MatchCollection’ cannot be converted to ‘String’.

1 Like

Hi @Chiru

Based on substring you can get the date And use @lakshman statement

Thanks
Ashwin.S

1 Like

Hi
Check the below Xaml
Hope it helps.
date_time.zip (11.0 KB)

1 Like

Got it… Thanks you all

1 Like