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

  • Home
  • SEARCH
  • 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 8906537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:40:56+00:00 2026-06-15T02:40:56+00:00

I have following Date Time in my database. If my current system Date time

  • 0

I have following Date Time in my database. If my current system Date time is “2012-11-24 03:50:00.000”, then there should be output as 3rd record. How can I get it by linq query?

1   2012-11-24 01:00:00.000 35466   True    False
2   2012-11-24 01:00:00.000 35466   True    False
3   2012-11-24 01:15:00.000 35466   True    False
4   2012-11-23 01:10:00.000 65456   True    False
  • 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-06-15T02:40:58+00:00Added an answer on June 15, 2026 at 2:40 am

    If you don’t absolutely have to do the query server-side, then the following pseudocode method will work:

      foreach value in the data set
            let distance = absolute value of ( data point - target data value )
    
      sort by distance, ascending
    
      choose first
    

    In C#, you can calculate time intervals easily with the DateTime.Substract method, and take the absolute value of the returned TimeSpan object’s Days property, for example.

    I am not too expert with SQL date manipulation, but I believe you can do the same sort of thing server side with something similar to:

      select * from table, abs(Datediff(datecolumn.table, sysdatetime)) as distance
      order by distance 
    

    and then use the first value.

    Sorry, I just noticed you want it in LINQ format, which lets you combine server side and client side work–something similar to this:

    (from q in datacontext.Table
    let distance = Math.Abs(q.Date.Subtract(DateTime.Today).Ticks)
    orderby distance
    select q).First();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following from a Microsoft SQL Server database for date/time value: 0x00009CEF00A25634
I have a JDBC current date and time insert into Mysql Database. It submits
I have the following data on a table tbl Admission : Date and Time
We have an application parsing date/time values in the following format: 2009-10-10 09:19:12.124 2009-10-10
I have a service that give me a date time string in the following
All, I have the following date: Wed Feb 01 2012 09:30:00 GMT-0600 (Central Standard
Assume that I'm adding the date / time into a mysql database and have
During testing I have failed to notice an incorrect date/time entry into the database
I have the following data set structure: date time_in_hours price Sep 03 08 9.76
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor

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.