I'd like to get the Date part of a DateTime value in an .NET entity framework query. I am not able to workaround by retrieving the date part in c# because consider following example:

var result = context.Products
  .Select(p => p.SomeMappedSqlFunction(p.CreateDateTime.Date)) // .Date is not supported
  .ToList();

Following functions are not mapped to an sql function by Sybase:

  • Date property of DateTime
  • System.Data.Objects.EntityFunctions.TruncateTime
  • System.Data.Entity.TruncateTime

The only solution i could imagine right now would be to write an sql function my own which does the conversion and map it to my edmx scheme. Is there really no out function mapped which converts/casts DateTime to Date?

Thank you very much ;)

asked 24 Jul '15, 05:17

dIeGoLi's gravatar image

dIeGoLi
1113
accept rate: 50%


I ended up mapping the date(...) function in my edmx scheme.

permanent link

answered 17 Sep '15, 05:36

dIeGoLi's gravatar image

dIeGoLi
1113
accept rate: 50%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×65
×15
×14

question asked: 24 Jul '15, 05:17

question was seen: 1,907 times

last updated: 17 Sep '15, 05:36