Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6767395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:56:45+00:00 2026-05-26T14:56:45+00:00

How can I convert DateTime into a formatted string? This is the line in

  • 0

How can I convert DateTime into a formatted string?

This is the line in the following query that needs help:

StartDate = string.Format("{0:dd.MM.yy}", p.StartDate)

The whole query:

var offer = (from p in dc.CustomerOffer
             join q in dc.OffersInBranch
             on p.ID equals q.OfferID
             where q.BranchID == singleLoc.LocationID
             let value = (p.OriginalPrice - p.NewPrice) * 100 / p.OriginalPrice
             orderby value descending
             select new Offer()
             {
                 Title = p.OfferTitle,
                 Description = p.Description,
                 BestOffer = value,
                 ID = p.ID,
                 LocationID = q.BranchID,
                 LocationName = q.CustomerBranch.BranchName,
                 OriginalPrice = SqlFunctions.StringConvert((decimal)p.OriginalPrice),
                 NewPrice = SqlFunctions.StringConvert((decimal)p.NewPrice),
                 StartDate = string.Format("{0:dd.MM.yy}", p.StartDate)
             }).First();

I get the following error message:

LINQ to Entities does not recognize the method ‘System.String ToString(System.String)’ method, and this method cannot be translated into a store expression.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:56:46+00:00Added an answer on May 26, 2026 at 2:56 pm

    EDIT: Now that I understand the question, I’m giving it another shot 🙂

    var offer = (from p in dc.CustomerOffer
                         join q in dc.OffersInBranch
                             on p.ID equals q.OfferID
                         where q.BranchID == singleLoc.LocationID
                         let value = (p.OriginalPrice - p.NewPrice) * 100 / p.OriginalPrice
                         orderby value descending
                         select new
                         {
                             Title = p.OfferTitle,
                             Description = p.Description,
                             BestOffer=value,
                             ID=p.ID,
                             LocationID=q.BranchID,
                             LocationName=q.CustomerBranch.BranchName,
                             OriginalPrice=SqlFunctions.StringConvert((decimal)p.OriginalPrice),
                             NewPrice=SqlFunctions.StringConvert((decimal)p.NewPrice),
                             StartDate=p.StartDate
    
                         })
                         .ToList()
                         .Select(x => new Offer()
                         {
                             Title = x.OfferTitle,
                             Description = x.Description,
                             BestOffer=value,
                             ID=x.ID,
                             LocationID=x.BranchID,
                             LocationName=x.CustomerBranch.BranchName,
                             OriginalPrice=x.OriginalPrice,
                             NewPrice=x.NewPrice,
                             StartDate=x.StartDate.ToString("dd.MM.yy")
                         }).First();
    

    I know it’s a bit long, but that’s the problem with Linq To SQL.

    When you use linq, the database call isn’t executed until you use something such as ToList() or First() that results in actual objects. Once that SQL call is executed by the first .First() call, you’re now working with .NET types, and can use DateTime stuff.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I convert this string, 12:00 AM , into a DateTime?
Just wondering how I can convert the following string into a datetime 111222, at
Anyway I can convert a datetime variable into string in SQL Server?
How can i convert String like 20100102 into datetime in a formate of dd/MM/yyyy?
I am trying to convert a mysql DATETIME into this format m/d/y but the
Hey looking to convert this string into datetime 20101119T162837 And then also how to
I have the following date: 2011-05-24T11:40:41Z How can I convert this into a Joda
I can't figure out how convert the datetime that wcf outputs into a datetime
How can i convert the datetime format below 2010-10-25 11:13:36.700 into 25-Oct-2010 or 2010-10-25
How can I convert a string 08:00 to a DateTime datatype? Im trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.