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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:10:41+00:00 2026-05-18T02:10:41+00:00

I’ve the following question: This is my Create-table: CREATE TABLE `mod_users` ( `u_id` int(11)

  • 0

I’ve the following question:

This is my Create-table:

CREATE TABLE `mod_users` (
  `u_id` int(11) NOT NULL auto_increment,
  `u_date` datetime NOT NULL,
  `u_type` int(1) NOT NULL default '',
  `u_adddate` datetime NOT NULL,
  PRIMARY KEY  (`u_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

u_type contains an int (doh) which represent a type of interval.

1 = one week
2 = two weeks
3 = one month
4 = one year

I want to select the first date after the current date which falls into the interval of the u_type – one day (so one week becomes 6 days, 2 weeks becomes 13 days, one month becomes: 1 month – 1 day, one year becomes: one-year -1 day) with a start of u_date. Sounds confusing right.

An example:
If an user has type 1 (one week) And u_date 2010-11-01 00:00:00 (Four days ago) I want to get the first occurrence after one week. In this case 'SELECT DATE_ADD(u_date,INTERVAL 6 DAYS) from mod_users WHERE u_id = 1'; (which gives 2010-11-07 00:00:00) How can i do this for u_type 3 or 4? something like 'SELECT DATE_ADD(u_date,INTERVAL 1 MONTH - 1 DAYS) from mod_users WHERE u_id = 1';?? This is not a valid query.

Also if the current date would be 2010-11-08 I Want to get the first occurrence after this date. In this case 2010-11-14. 00:00:00. This reject this query 'SELECT DATE_ADD(u_date,INTERVAL 6 DAYS) from mod_users WHERE u_id = 1'; Cause 6 days is not the right interval at this query.

Hope some of you can help? I can use php and mysql so these queries are just used as an example. I’m really stuck here so just hints or clues would be appreciated.

  • 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-18T02:10:42+00:00Added an answer on May 18, 2026 at 2:10 am

    In MySQL you can add intervals directly to a datetime field, so u_date + INTERVAL 1 MONTH - INTERVAL 1 DAY should work fine.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this

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.