how to set date format in eval asp.net

RAVI 1,056 Reputation points
2025-02-25T08:36:02.3033333+00:00

Hello

this is my date eval <%#Eval("Date", "{0:dd/MMM/yyyy}")%> when i convert to excel i want excel filter to be look like this so what to change my eval so that it can look like as below111

ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
387 questions
{count} votes

1 answer

Sort by: Most helpful
  1. XuDong Peng-MSFT 11,336 Reputation points Microsoft Vendor
    2025-02-25T09:56:58.8266667+00:00

    Hi @RAVI

    date eval <%#Eval("Date", "{0:dd/MMM/yyyy}")%>

    If you want the date to be displayed in a format like "18-Feb-25", you need to set the format to dd-MMM-yy.

    1. dd : The day of the month, from 01 to 31.
    2. MMM : The abbreviated name of the month.
    3. yy : The year, from 00 to 99.

    In data bind, it should look like:

     <%# Eval("Date", "{0:dd-MMM-yy}") %>
    

    For more details about the date and time format, please refer to this doc: https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

    Best regards,

    Xudong Peng


    If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

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