I have an output datatable from database, few of those columns have datetime in the format (yyyy-MM-dd HH:mm:ss). What I need is to convert those date columns in yyyy-MM-dd format and then I am printing that table to word document using word activities(so that I can get a table like structure).
I have tried a for each row after fetching the datatable from database and using an assign activity row(“Column”.Trim) = Convert.ToDateTime(row(“Column”.Trim).ToString).ToString(“yyyy-MM-dd”)
But when I reference the datatable in the word activity, these columns are not getting updated. Am I missing any step here? Do share your insights!
PS: The datatable has only 1 output row so I don’t mind using loop in place of linq queries/vb scripts.
I saw the build datatable activity you used, the column format is a string, maybe that’s why its working. But as I said I am fetching the table from the database and the column is of datetime format.
I have attached the workflow please look at it again. DT.7z (34.3 KB)
OK. But don’t put .Trim on the end of the column name. .Trim is for removing extra spaces from the beginning and end of the string. No need for that, just reference the correct column name.
If you need to change how the dates are output, you’ll add a string column to the datatable, For Each Row and convert the datetime to the string format you want, into the string column. Remove the datetime column. Write the datatable and you’ll get the result you want.