Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 703419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:49:45+00:00 2026-05-14T03:49:45+00:00

In sql 2005, instead of building a query from dateparts year, month and date,

  • 0

In sql 2005, instead of building a query from dateparts year, month and date,

is there an more succinct way of writing the where clause?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:49:45+00:00Added an answer on May 14, 2026 at 3:49 am

    In SQL 2000 and SQL 2005 you can use a nice select statement to remove the time component from a DateTime, ie

    SELECT DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0)
    

    will return 6-Apr-2010 (well for today only).

    So combined with marc_s’s answer, you’d want

    SELECT (list of fields)
    FROM dbo.YourTable
    WHERE dateValue BETWEEN DATEADD(dd, DATEDIFF(dd,0,'MY Date and Time, But I Only Want Date'), 0) 
    AND DATEADD(dd, DATEDIFF(dd,0,'MY Date and Time, But I Only Want Date'), 1)
    

    Edit: Changed to suit requirements, note the 1 in the second DateAdd (this adds the days it has been from the beginning to 1 (instead of 0), making it 7th Apr 2010 00:00:00)
    If you want 6th Apr 23:59:59 you take a second away from the second date

    DATEADD(ss,-1,'My DateTime')
    

    Final Call would become

    DATEADD(ss,-1,DATEADD(dd, DATEDIFF(dd,0,'MY Date and Time, But I Only Want Date'), 1))
    

    Ok that’s alot of info at once! Hope it all makes sense 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server 2005 (not 7.0), is there any reason to use NVARCHAR(255) instead
Is there a way in T-SQL (SQL Server 2005) to assign a whole record
Is there any other way to retrieve data from a remote server in SQL
HI, Using SQL server 2005 I have the following query: SELECT contact_id ,YEAR(date_created) AS
Starting in SQL 2005, VARCHAR(MAX) is no longer limited to 8000 bytes, it instead
I'm using MS SQL 2005 and I have created a CTE query to return
I'm using DTS to import data from an Access database to SQL Server 2005.
I am trying to create a query in MS SQL 2005 that will return
In SQL 2005 stored proc I need to run a query that contains a
SQL Server 2005: The following view SELECT CONVERT(VARCHAR(20), keyedtimestamp, 101) as KeyedDate FROM TMSSTATFILE_STATS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.