web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / add today date column ...
Power Automate
Unanswered

add today date column in the data table

(0) ShareShare
ReportReport
Posted on by 22

Hi. 

i made automation for my work. 

everyday, my rpa visit the web site and extract data and save it in the excelfile.

 

but problem is that there is no date in the data table. 

i try to insert date column but there is no way in automate desktop. 

 

is there any way to insert date column in data table? 

 

 

dexter2_0-1714377911812.png

 

I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at

    Hi @dexter2 ,

     

    As per my understanding,instead of adding Date&Time column to DataTable,add the column to the excel and write the current date and time to each row.

    Please find the attached solution.

     

    VishnuReddy1997_0-1714379339371.png

     

    Code:

    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\input.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.InsertColumn Instance: ExcelInstance Column: $'''DateandTime'''
    Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
    SET RowValue TO 2
    LOOP FOREACH CurrentItem IN ExcelData
     Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: CurrentDateTime Column: $'''B''' Row: RowValue
     Variables.IncreaseVariable Value: RowValue IncrementValue: 1
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

  • Verified answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    If VishnuReddys1997's solution doesn't work for you then you could use Run .NET script with C# and add Date column with todays date as default value.

    Add Run .NET script -action:
    Language C#
    Press Script parameters Edit -button and this window opens:

    eetuRobo_5-1714382927472.png

    Input those parameters. Just remember to change the Input value to the dataTable that you are using

    Then add .NET code to run:

    eetuRobo_3-1714382729908.png

    // Add a column with default value set to DateTime.UtcNow.Date
    DataColumn dateColumn = new DataColumn("Date", typeof(DateTime));
    dateColumn.DefaultValue = DateTime.UtcNow.Date;
    dt1.Columns.Add(dateColumn);
    
    // Convert DataTable to DataView and then back to DataTable
    dt1 = dt1.DefaultView.ToTable();


    Or just copy paste this action to your PAD and change the Script parameters Input Value to your dataTable

    Scripting.RunDotNetScript Language: System.DotNetActionLanguageType.CSharp Script: $'''// Add a column with default value set to DateTime.UtcNow.Date
    DataColumn dateColumn = new DataColumn(\"Date\", typeof(DateTime));
    dateColumn.DefaultValue = DateTime.UtcNow.Date;
    dt1.Columns.Add(dateColumn);
    
    // Convert DataTable to DataView and then back to DataTable
    dt1 = dt1.DefaultView.ToTable();
    ''' @'name:dt1': InputDataTable @'type:dt1': $'''Datatable''' @'direction:dt1': $'''InOut''' @dt1=> dtOut



    Table before Date column:

    eetuRobo_2-1714382692563.png

     

    After adding Date column:

    eetuRobo_1-1714382666987.png

     

  • dexter2 Profile Picture
    22 on at

    Thanks a lot. It is works perfectly!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard