If this is what you meant , then assign the given date in string format to a date time variable( dt) as in the expression editor. Then the expression in the message box will you the month.
I have replicated your scenario, and below is the detailed solution
Input :
Output :
Below is the Code :
(From row In dt_Input.AsEnumerable
Where Not String.IsNullOrEmpty(row("PO Date").tostring)
Let dateCol = DateTime.ParseExact(row("PO Date").ToString, "MM/dd/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture)
Select dt_Input.Clone.Rows.Add({row(0).ToString, dateCol.ToString("dd-MM-yyyy"), dateCol.ToString("MMM")})).CopyToDataTable
Code Explaination :
Filters rows with non-empty “PO Date” values.
Converts the “PO Date” string to a DateTime type using the specified format.
Formats the date to “dd-MM-yyyy” and extracts the month from it.
Creates a new DataTable with same structure as input and fills all the details to it
For Each Row in dtPO
a. Assign → poDate = DateTime.ParseExact(row(“PO Date”).ToString(), “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture)
b. Assign → monthValue = poDate.ToString(“MMMM”)
c. Assign → row(“Month”) = monthValue
Follow the below steps,
→ Use the Read range workbook activity to read the Input excel and store in a datatable called DT.
→ Then use the Assign activity and create a datatable datatype varibale called OutputDT. Then give the below LINQ Expression,
- Assign -> OutputDT = (From row In DT.AsEnumerable()
Let PoDate = row("PO Date").ToString()
Let Month = If(Not(String.IsNullOrEmpty(row("Month").ToString()) OrElse String.IsNullOrWhiteSpace(row("Month").ToString())), DateTime.ParseExact(PoDate, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MMM"), row("Month").ToString())
Select DT.Clone().Rows.Add(row("PO Name").ToString(), PoDate, Month)
).CopyToDataTable()
→ Then use the Write range workbook activity to write the OutputDT to the same excel sheet.
This LINQ query goes through each row in the DataTable, converts the “PO Date” to a DateTime object, extracts the abbreviated month name (e.g., “Aug”), and populates the “Month” column.
Step 3: Write the Data Back to Excel
Use the Write Range activity:
After processing the data, use the Write Range activity to write the updated DataTable back to the Excel sheet.