date function in Sql

Jonathan Brotto 420 Reputation points
2024-09-24T18:11:46.69+00:00

I have a timestamp where I want to query only based on the date and exclude time.

SQL Server | SQL Server Transact-SQL
Developer technologies | Transact-SQL
SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.6K Reputation points
    2024-09-24T18:25:00.93+00:00

    Try the “cast-as-date”, for example:

    select *
    from MyTable
    where cast(column1 as date) = '2024-09-24'
    

    where column1 is a datetime value.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.