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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:19:55+00:00 2026-05-26T18:19:55+00:00

I have a query regarding to find out which is day (in given list)

  • 0

I have a query regarding to find out which is day (in given list) is nearest day from today.

For example

day_list is Mon, Tue, Fri, Sat
and today is Wed

Now If we calculate days on paper,

Wed to Mon = 5 days
Wed to Tue = 6 days
Wed to Fri = 2 days
Wed to Sat = 3 days 

So answer will be Fri .

But in code, how can I implement this logic? Or is there any other way to optimize its process (regarding if_else)?

  • 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-26T18:19:55+00:00Added an answer on May 26, 2026 at 6:19 pm

    What I have in mind is below but probably you should change a little bit to fit your need.

    Give your days of week number from 0 to 6.

    Sun = 0; Mon = 1; Tue = 2; etc.

    If you just have some of days, keep the numbers. For example, if you have only Mon, Tue, Fri, and Sat then keep the number respective to the days, i.e. 1, 2, 5, and 6.

    Now, if you want to know the “distance” between those days from Wed (which has a number 3), you can do this math:

    distance = (theNumberOfYourDayInList - 3) mod 7

    7 is the number of the days, by the way.

    So if you want to know the distance between:

    Wed to Mon: distance = (1 - 3) mod 7 which is 5.

    Wed to Fri: distance = (4 - 3) mod 7 which is 1.

    Wed to Tue: distance = (2 - 3) mod 7 which is 6.

    Turn those logic into codes are trivial and I think you shouldn’t face any problems.

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

Sidebar

Related Questions

I have a query regarding the directory returned from Path.GetTempPath() function. It returns C:\Documents
Background info I have a query regarding a questions from Sierra & Bates, SCJP
I have a query that is dynamically built after looking up a field list
I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
I have a query on my database as such: SELECT * FROM expenses WHERE
I have a query that I'm executing from a .NET application to a SQL
I have a query regarding how delegates work. My understanding was that delegates take
I have tried to find out what's wrong. The table is conditions_loop. One column
Url routing and IIS7 03-24-2011 04:24 PM Hi, I have a query regarding Url
I have a problem reading out multiple rows that get returned from an SQLite

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.