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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:08:39+00:00 2026-05-26T09:08:39+00:00

I have a reminder table in my database that has 2 columns to store

  • 0

I have a reminder table in my database that has 2 columns to store the ActionDay and ReminderDay. These days are both stored as integers: 0 (sun) -> 6 (sat) to represent the days of the week.

When I load my page I’d like to show the next ActionDay date and along with the ReminderDay date.

I can work out the next ActionDay date using this:

public static class DateTimeExtensions
{
    public static DateTime Next(this DateTime date, DayOfWeek weekday)
    {
        return (from i in Enumerable.Range(0, 7)
                where date.AddDays(i).DayOfWeek == weekday
                select date.AddDays(i)).First();

    }
}

I’m having some trouble working out the previous date from the ActionDay.

For example, (using today’s date of 26 Oct 2011):
If the ActionDay is ‘3’ and the ReminderDay is ‘2’ then I expect
‘Wed, 26 Oct’ for the ActionDay and ‘Tues, 25 Oct’ for the ReminderDay.

If the ActionDay is 0 and the ReminderDay is 6 I’d expect
‘Sun, 30 Oct’ and ‘Sat, 29 Oct’

Any suggestions on how I might be able to get this Reminder date? I’d also be interested to know if there are any good c# datetime extensions/snippets as it might be easier to plug in something that someone else has tested than writing my own here 🙂

Thanks,
Rich

  • 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-26T09:08:40+00:00Added an answer on May 26, 2026 at 9:08 am

    You can calculate the difference between the ActionDay and ReminderDay and then call the AddDay() function on the DateTime representing the action day to get the DateTime for reminder day:

    // here a stands for the number representing the action day, and r for the reminder day
    // a and r are both integers from 0 to 6
    int diff;
    if (a >= r)
    {
        diff = a - r;
    }
    else
    {
        diff = a + 7 - r;
    }
    
    DateTime reminderDateTime = actionDateTime.AddDays(-1 * diff);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that is is sorted 1st by Reminder Date then ID
I have a simple table made up of two columns: col_A and col_B .
I have seen somewhere that you can't add a reminder to iPhone calender from
I have a database, tvguide and these are the values: id bigint 255 UNSIGNED
I have a reminders table in my apps database FieldName = 'id' FieldName =
I created a SQLite database via SQLiteManager. I have a table called Envelopes, and
So at the moment I have a simple reminder app that you enter some
So I have a table with only two columns and one row. The second
I have a database that I want to add a column to, I changed
I have an Excel worksheet that has 30k+ rows. I'd like to cut the

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.