Formatting date for webform mail message

briggzee 1 Reputation point
2022-05-11T04:48:57.053+00:00

In my ASP.Net VB app I have an tournament entry form that uses birth date. I pass the date to the database in the following format yyyy-mm-dd and it works fine. In the web form mail message I send to the applicant I want the birth date to display as MMM-dd-yyyy (eg Jan 1 2022). In the code behind I've tried various methods to re-format the date but keep getting various errors. The line of code in the mail message body is the following.
"<p>BIRTH DATE: " & HttpUtility.HtmlEncode(BirthDate) & "</p>" & .

Any help will be appreciated.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,248 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,066 Reputation points
    2022-05-11T06:08:23.43+00:00

    Hi @briggzee ,
    Do you care of convertering data format in the code behind? You could use this:

    xxxxx.ToString("MM-dd-yyyy")  
    

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    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.

    1 person found this answer helpful.
    0 comments No comments