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 / SQL Query to excel cha...
Power Automate
Unanswered

SQL Query to excel changes Date format on DataTable

(0) ShareShare
ReportReport
Posted on by 33

I hav an excel file with dates dd-mm-yyyy format. I'm doing a sql query to de excel and then pasting the data to a new excel file.

 

The Original data look like this:

franco2_0-1709906521182.png

 

Inside the data table it changes to mm-dd-yyyy format:

franco2_1-1709906619910.png

 

I have tried changing it back with a VBScript in the new excel file. But it does not work because when the data is pasted is set to dd-mm-yyyy format automatically, so it thinks the mm is dd.

 

If anyone can help me I would gladly appreciate it.

Thanks

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @franco2 

    It appears that your system date format is set to "mm-dd-yyyy," which may be causing changes in your flow as well. If your system date format is "mm-dd-yyyy," consider switching it to "dd-mm-yyyy" format. This adjustment should resolve the issue.

     

  • franco2 Profile Picture
    33 on at

    I just checked the setting and they are already in dd-mm-yyy format.

    franco2_0-1709908942900.png

     

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @franco2 

    Then macro is another option.

    Please refer the below link - https://powerusers.microsoft.com/t5/Power-Automate-Desktop/How-to-use-date-formatting-in-datatable/m-p/2638640#M37675 

  • franco2 Profile Picture
    33 on at

    Thank you very much! . I will do a macro as you suggest, seems to be the way.

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @franco2 

     

    Please try macro like below(Change as required) and let us know.

    Sub ChangeDateFormat()
     Dim ws As Worksheet
     Dim lastRow As Long
     Dim rng As Range
     Dim cell As Range
     
     ' Set the worksheet where your data resides
     Set ws = ThisWorkbook.Sheets("Sheet1") ' Replace "Sheet1" with your actual sheet name
     
     ' Find the last row in column G
     lastRow = ws.Cells(ws.Rows.Count, "G").End(xlUp).Row
     
     ' Set the range for column G
     Set rng = ws.Range("G1:G" & lastRow)
     
     ' Loop through each cell in the range
     For Each cell In rng
     If IsDate(cell.Value) Then
     ' Change the date format to "dd-mm-yyyy"
     cell.Value = Format(cell.Value, "dd-mm-yyyy")
     End If
     Next cell
    End Sub
    


    --------------------------------------------------------------------------------------------------------------------------
    🔍Found my answer helpful? Please consider marking it as the solution!  Thank you! 🙌

     

     

     

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard