Share via

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
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other

1 answer

Sort by: Most helpful
  1. Viorel 126.8K 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.