Extract dateTime Format as string

Hi I would like to extract dateTime format cell from excel and convert it to String (using for each row and datatable) like so:

I want to print out Apr-19 instead of 4/1/2019

1 Like

Hi @zefang
–we can use excel application scope and pass the file path of the excel
–use read range activity and get the output a varaible named outdt
–use a for each row loop and pass th above variable as input
–inside this loop use a write line like this
out_date_value = row(1).ToString
–then use a assign activity to get the value like you expect
out_date_value = Datetime.ParseExact(out_date_value.Substring(0,10),“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MMM-yy”)

Kindly make sure that the format that is mentioned here should match with the format of out_date_value, FOR THAT USE A WRITE LINE WITH VALUE AS out_date_value AND CHECK WHAT IS THE FORMAT AND MENTION THE FORMAT WHILE PARSING DATETIME

Cheers @zefang


Hi @zefang
Get the Values from excel And Just Use DateVar.ToString(“MMMM-yy”) It will Conver date In Month-Year Format.

1 Like

Hi @jitendra_123 thank you for the reply.
can i ask, as the row i am extracting is a mix of string and dates, I want to use the IF activity to check if it is a dateTime then i can use your method… How do I do that?

You can do One thing Either you can convert both dates as in string or in datetime You already know how to convert in String. you can convert into date time as Convert.todatetime(YourStringvariable), Then you can compare easily.

@jitendra_123 because im using For each loop,
for “Row” in rowtable, the ROW might not be a dateTime object. Can we still do that?

We can do this For your understanding i have uploaded sample workflow just have look at it, surely it will help you.
RegardsSampleDatetime.xaml (7.3 KB)