Hi @RAVI,
Thanks for reaching out.
The current date eval format:
<%#Eval("Date", "{0:dd/MMM/yyyy}")%>
displays dates like 18/Feb/2025, but when exported to Excel, it may not align with the desired filter format (e.g., 18-Feb-25). Simply changing the Eval format to:
<%# Eval("Date", "{0:dd-MMM-yy}") %>
will adjust the display in the web page to 18-Feb-25.
- dd: The day of the month, from 01 to 31.
- MMM: The abbreviated name of the month.
- yy: The year, from 00 to 99. To ensure the exported Excel file displays and filters dates as needed, the ASP.NET Eval method only formats the data for the web page and does not control Excel's column formatting. You should export the raw DateTime value (not a preformatted string) so Excel can store it as a true date. For proper Excel date formatting, you should use an Excel library such as Open XML to define the date format during the export process. This allows Excel to recognize the column as dates and apply filters like 18-Feb-25 correctly.
For more details about date and time format strings, please refer to this doc: https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
Hope this helps! If you agree with my suggestion, feel free to interact with the system accordingly!