2

I use this code to get Server Date but I really don't understand.CreateDateTime() is not a sql function.so what is it?

DateTime ServerDate = Entities.CreateQuery<DateTime>("CurrentDateTime()").AsEnumerable().First();

I think the string that comes in CreateQuery function must be a sql query.Is it wrong?

I have open the SSMS and write CurrentDateTime() and i got an error,I have test this too: SELECT CurrentDateTime(), and i got an error agian,CurrentDateTime() is not a sql function

Saleh
  • 2,982
  • 5
  • 34
  • 59
  • possible duplicate of [How to ask database server for current datetime using entity framework?](http://stackoverflow.com/questions/2585272/how-to-ask-database-server-for-current-datetime-using-entity-framework) – Mitch Wheat May 16 '11 at 04:15
  • 1
    No,I have copy the code from that question but I want to know what is CurrentDateTime.I think you didn't read my question carefully. – Saleh May 16 '11 at 04:18
  • @LightWing: I read your question. Carefully. – Mitch Wheat May 16 '11 at 04:19
  • I the question that you have put its link he didn't discuss about CurrentDateTime(). – Saleh May 16 '11 at 04:21
  • I have open the SSMS and write CurrentDateTime() and i got an error,I have test this too: SELECT CurrentDateTime(), and i got an error agian,CurrentDateTime() is not a sql function – Saleh May 16 '11 at 04:23
  • 1
    That's correct: CurrentDateTime() is not a sql function, its part of EF: http://msdn.microsoft.com/en-us/library/bb738563.aspx – Mitch Wheat May 16 '11 at 04:24

1 Answers1

9

CurrentDateTime() is one of the Date and Time Canonical Functions of the Entity SQL.

Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96