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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:05:05+00:00 2026-05-15T09:05:05+00:00

How do I do something like the following SELECT ADDDATE(t_invoice.last_bill_date, INTERVAL t_invoice.interval t_invoice.interval_unit) FROM

  • 0

How do I do something like the following

SELECT ADDDATE(t_invoice.last_bill_date, INTERVAL t_invoice.interval t_invoice.interval_unit) 
  FROM t_invoice

…where the column t_invoice.last_bill_date is a date, t_invoice.interval is an integer and t_invoice.interval_unit is a string.

What I like about the ADDDATE() function is that if I write a

SELECT ADDDATE('2010-01-31', INTERVAL 1 MONTH)

It conveniently returns the last day of February – 2010-02-28. So it knows that 1 MONTH means 28 days for Feb (29 on leap year), 31 if odd number month, 30 if even number month. I would like to preserve this feature in my query.

Basically, I want to determine a person’s next bill date based on his desired billing frequency. Is there a better way to achieve this?

  • 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-15T09:05:06+00:00Added an answer on May 15, 2026 at 9:05 am
    SELECT t_invoice.last_bill_date +  INTERVAL 
       CASE t_invoice.interval_unit 
        WHEN 'minute' THEN t_invoice.interval 
        WHEN 'hour' THEN t_invoice.interval*60
        WHEN // etc...
        END MINUTE as col1
     FROM t_invoice
    

    OR

    SELECT 
       CASE t_invoice.interval_unit 
        WHEN 'minute' THEN t_invoice.last_bill_date +  INTERVAL t_invoice.interval MINUTE
        WHEN 'hour' THEN t_invoice.last_bill_date +  INTERVAL t_invoice.interval HOUR
        WHEN // etc...
        END as col1
     FROM t_invoice
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following method, when called with something like String val = getCell(SELECT col FROM
I would like to use something like the following: SELECT city FROM cities WHERE
How should i go about doing something like: IF the following select has any
I'm doing something like the following: SELECT * FROM table WHERE user='$user'; $myrow =
I need to do something like the following SELECT p.name, (SELECT COUNT(p.id) FROM products
Hi I'd like to do something like the following: SELECT * FROM tbl_article JOIN
is it possible to do something like the following in MySQL: SELECT * FROM
Basically I have a mysql query something like the following: mysql_query(SELECT n.title, v.value FROM
I'm trying to do something like the following: @special_attributes = Model.new.methods.select # a special
I have something like the following code:: <xsl:variable name=sample> <xsl:copy-of select=//foo> <xsl:copy-of select=//bar> </xsl>

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.