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 7606753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:29:18+00:00 2026-05-31T00:29:18+00:00

I want to make a SQL query that gets todays date and the most

  • 0

I want to make a SQL query that gets todays date and the most recent date from a date column. So if I have three records in my database that have the following dates:

  • March 8, 2012
  • March 2, 2012
  • December 8, 2011

I want the SQL query to return all records for March 8, 2012 and March 2, 2012 (most recent date). How can I do this?

I can date today’s date using:

CONVERT( varchar(100), DATEADD( DAY, 0, getdate() ), 111)

Thank You

Edit:
Thanks everyone. I just have one more question. I have created two views:

create view with top dates
CREATE VIEW topDates AS
select DISTINCT TOP 3 replace(CONVERT(VARCHAR(20),date,111),'-','/') AS dates from     CSAResults.dbo.Details

create view dateTwo
select *
from (select ROW_NUMBER() over (order by dates desc) as srNo, dates
    from topDates)
    AS employee
    WHERE srNo=2

And now I want to select * from my DB where a column is equal to the ‘dates’ column from the view ‘dateTwo’

select buildNumber
from CSAResults.dbo.Details
where buildNumber LIKE '%Main '+ (SELECT dates FROM dateTwo) + '%'

But this returns nothing.

Thanks

  • 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-31T00:29:20+00:00Added an answer on May 31, 2026 at 12:29 am

    You can do the following:

    select date
    from yourtable
    where 
    (
        date = Convert(varchar(10), getdate(), 101)
        OR
        date IN (SELECT Max(date) 
                    FROM yourtable
                    WHERE date!= Convert(varchar(10), getdate(), 101))
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MS SQL view that I want to make available as a
I want make sql query which will insert values from one table to another
I want to make one question about oracle/sql query. I have some data like
Suppose I have a SQL query that looks like this: SELECT fName from employees
I have made an SQL query that picks out web statistics from a database.
I have an SQL query that takes these parameters: @SearchFor nvarchar(200) = null ,@SearchInLat
I have a SQL query that I'm currently solving by doing two queries. I
I have a SQL query that I cant wrap my mind around. I do
In one of my process I have this SQL query that take 10-20% of
Ok, I have a SQL query that I'm trying to generate that will combine

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.