Create date from day, month and year

Hello friends,
@AshwinS2 , @arivu96, @Rammohan91, @balupad14, @Florent_Salendres, @vvaidya, @Palaniyappan, @loginerror, @MAHESH1, @Manjuts90

I need to transform in date format the variables day, month and year read from three cells of an Excel file.
How to read the three variables and create the date from

?
Thank you,
cami

1 Like

hope this expression would help you in this
—use a excel application scope and pass the file path as input
—inside the scope use a read range activity and get the output with a variable of type datatable named dt
—now use a for each row loop and pass the above variable as input
—inside the loop use a assign activity like this
str_date = row(0).ToString+”/“+ row(1).ToString+ “/“+row(2).ToString

Where str_date is a variable of type string

Cheers @CamiCat

Thank you so much @Palaniyappan.
how to transform the string in a datetime format?
Thank you,
Cami

Fine the expression would be like this
After that string variable assigned again use a assign activity like this

Str_date = DateTime.ParseExact(str_date,”dd/MM/yyyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString()

If we remove the ToString atlast it will become a DateTime variable and use a DateTime variable in the left side of assign activity as well

That’s all buddy
Cheers @CamiCat

1 Like

thank you @Palaniyappan.
How to pass to format “yyyy/MM/dd”?
Thank you,
Cami

1 Like

Like this buddy
Str_date = DateTime.ParseExact(str_date,”dd/MM/yyyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy/MM/dd”)

Cheers @CamiCat

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.