Skip to main content
Newcomer
July 12, 2022

Date Format lost when exporting data from Grid View by Export to Excel XML / SQL Query

  • July 12, 2022
  • 1 reply
  • 0 views

Hello,

 

I created a Grid View to export data from database by SQL query. Some columns should be in number format and others in date format. I defined date format in both SQL query and in Grid View. But when I export data by right click from grid view -> Export To Excel XML, all columns are in text. How can I change default setting of XML Export so that columns will have correct formats ?

Thanks in advance.

Summer

 

Format in SQL Query:

FORMAT(ActiveDate, 'dd/MM/yyyy') as BuildingDate,

 

Format in Grid View:

ColumnName = BuildingDate, DataFormatString = dd/MM/yyyy,

 

Export XML file:

Summer_0-1657613561932.png

 

 

 

1 reply

Newcomer
July 12, 2022

don't use the FORMAT in SQL, you can do the formatting on the gridview itself. When you use format in SQL, it converts the datatype in SQL to a text.