Search code examples
c#ef-core-2.2ef-core-3.1

How to Convert Formated Date string to upper case in EF Core Select statement


I want to display all the products with manufacture date in the format (DD-MMM-YYYY HH:MM) in the below code I'm getting the date format in lower case. I need to display in upper case (eg 02-FEB-2020 11:43). How to convert to upper case?

_dbContext.Product
          .Select(data => new
                          {
                            ProductId = data.ProductId,                  
                            ProductManufactureDate = data.ProductManufactureDate.ToString("dd-MMM-yyyy hh:mm"),
                          }).ToList();

Solution

  • replace this line code

    ProductManufactureDate=(data.ProductManufactureDate.ToString("dd-MMM-yyyy hh:mm")).ToUpper(),