Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.

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

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

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

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 24 Jul '15, 05:17

question was seen: 6,144 times

last updated: 17 Sep '15, 05:36