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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:03:53+00:00 2026-06-08T03:03:53+00:00

For example, a user can view his password if today is Monday or Tuesday

  • 0

For example, a user can view his password if today is Monday or Tuesday and if his schedule is within the time frame (given), compared to the current system time, but even if Today is Monday or Tuesday, if his given time is, let’s say 1:30-5:30PM, and it’s not yet or it’s already past that time, he won’t be able to view his password.

I hope you get the drill. The code below works fine, however, if I put the same day twice, like, Tuesday and Tuesday, there happens to be a conflict. How do I fix this conditional statements? Thanks.

Here’s my code:

DateTime systemtime = DateTime.Now;
DateTime timestart = Convert.ToDateTime(txtTimestart.Text);
DateTime timeend = Convert.ToDateTime(txtTimeend.Text);
var systemday = DateTime.Now.DayOfWeek.ToString();
var day1 = Convert.ToString(txtDay1.Text);
var day2 = Convert.ToString(txtDay2.Text);

if (systemday != day1 || systemday != day2)
{
    if (systemtime < timestart || systemtime > timeend)
    {
        MessageBox.Show("You are not authenticated to view your password.", "Get Password Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
    }
    else
    {
        MessageBox.Show("Your password is ...", "Get Password Success", MessageBoxButtons.OK, MessageBoxIcon.None);
        return;
    }
}
else
{
    if (systemtime < timestart || systemtime > timeend)
    {
        MessageBox.Show("You are not authenticated to view your password.", "Get Password Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
    }
    else
    {
        MessageBox.Show("Your password is ...", "Get Password Success", MessageBoxButtons.OK, MessageBoxIcon.None);
        return;
    }
}
  • 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-08T03:03:55+00:00Added an answer on June 8, 2026 at 3:03 am

    Taking your example, this line of code means: if current day(system day) is not monday or not tuesday.

    if (systemday != day1 || systemday != day2)
    

    Now if today is tuesday then it is not monday which makes first comparison true and it will enter in the if block. if today is monday then it is not tuesday which makes second comparison (Systemday != day2) true. If today is not monday and tuesday then it makes both comparison (systemday != day1 || systemday != day2) true. In short your code will never fall in else.

    Now for your problem use

    if (systemday == day1 || systemday == day2)
    { 
        if(systemtime>=timestart && systemtime <=timeend)
        {
            MessageBox.Show("Your password is ...", "Get Password Success", MessageBoxButtons.OK, MessageBoxIcon.None);
            return;
        }
        else
        {
            MessageBox.Show("You are not authenticated to view your password.", "Get Password Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To reset password, user should go to link that contains token: example.com/password-change/?token=8125b6da86694a19b5d76f30a04c9db8 In view
On my site, user profiles can be reached by the url www.example.com/user/profile.php?uid=3 I want
Why to restrict allowed usernames by different rules? For example why can't user have
How can I create a user control like the Textbox? For example when I
As user logged in, he had provided his name and raw password which was
Example user input: PA1 9 //correct PJ1 9 //wrong, error printed Invalid row because
This is a question best illustrated by example: User goes to Site A ,
I am adding auction-based data to my system. For example: user's timezone is :
I need to implement Online Help in my Java Web Project. For Example User
Example: the user fills in everything but the product name. I need to search

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.