Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

How to return only the Date from a SQL Server DateTime datatype

SELECT GETDATE()

Returns: 2008-09-22 15:24:13.790

I want that date part without the time part: 2008-09-22 00:00:00.000

How can I get that?

Answer*

Cancel
3
  • select {fn current_date()} as today works for me.
    – brianary
    Commented Dec 2, 2019 at 18:26
  • @brianary - That's nice, but it is not ANSI SQL.
    – lit
    Commented Dec 8, 2019 at 17:28
  • That's fair enough, and your answer is nicely portable, but I figured as long as we're working around T-SQL, this also works (and shows that implementing ANSI CURRENT_DATE would be trivial for MS).
    – brianary
    Commented Dec 8, 2019 at 18:28