Logic app workflow to insert record from Excel File to SQL Table issue with date column getting inserted as Text or Number.

Niren Adhikary (NAD) 146 Reputation points
2022-08-10T07:11:53.317+00:00

Hi,

I am trying to insert records from excel to sql table, it is working as expected but having issue with data type for columns with date is getting inserted as number in sql table.

229827-image.png

Example of a column with date

229837-image.png

But when it is inserted into sql table it is getting inserted as number instead of the above format in excel. Excel has date format.

If I check expand the logic app flow for the insert sql the field appears as below which is not same as excel record (2022-08-01)

229816-image.png

Azure SQL Database
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruno Lucas 4,436 Reputation points MVP
    2022-08-10T08:46:53.79+00:00

    Hi @Niren Adhikary (NAD)

    Did you try an expression like: https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#formatdatetime

    229896-image.png

    but I see you have yyyy-MM-dd, you may need to split by "-" and reorder to dd-MM-yyyy before using formatdatetime

    a split would look like this:
    formatDateTime(concat(split(outputs('Compose'),'-')[2],'-',split(outputs('Compose'),'-')1,'-',split(outputs('Compose'),'-')[0]))

    on your case replace with the excel field

    formatDateTime(concat(split(body('Get_a_row')?['Date_Delivered'])[2],'-',split(body('Get_a_row')?['Date_Delivered'])1,'-',split(body('Get_a_row')?['Date_Delivered'])[0]))

    maybe a reorder without format may do it

    concat(split(body('Get_a_row')?['Date_Delivered'])[2],'-',split(body('Get_a_row')?['Date_Delivered'])1,'-',split(body('Get_a_row')?['Date_Delivered'])[0])

    Please don't forget to click on "Accept Answer" or the vote button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.