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

  • Home
  • SEARCH
  • 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 3497838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:25:09+00:00 2026-05-18T12:25:09+00:00

I have two date columns, domain_renew_date and hosting_renew_date . I am trying to show

  • 0

I have two date columns, domain_renew_date and hosting_renew_date.
I am trying to show the rows which need to be renewed in the next x days.
But if i order by one column then the other, some dates which are close to the current date will be ignored because the other column doesn’t need renewing.

Is it possible to compare two columns for the largest value and use that value to order by?

This is what i have at the moment, but i have just found out ‘greatest’ doesn’t do what im trying to make it do.

"SELECT *
FROM `domains` as Domain
WHERE (`domain_renew_date` < '".$date."' AND `domain_renew_date` != '0000-00-00')
OR (`hosting_renew_date` < '".$date."' AND `hosting_renew_date` != '0000-00-00')
ORDER BY greatest(`domain_renew_date`, `hosting_renew_date`) ASC"

Thanks.

  • 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-18T12:25:10+00:00Added an answer on May 18, 2026 at 12:25 pm

    Or even more simple


    SELECT if(domain_renew_date > hosting_renew_date, domain_renew_date, hosting_renew_date) as greater_date
    FROM
    domains
    WHERE hosting_renew_date >= '".date."' OR domain_renew_date >= '".$date."'
    ORDER BY greater_date ASC

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

Sidebar

Related Questions

I have a table in an Openoffice Database, containing two date columns. I'm trying
I have two arrays: var columns = ["Date", "Number", "Size", "Location", "Age"]; var rows
I have two tables both of which have columns StartDate and EndDate. I'm trying
I need to add two DATE columns to an already existing table. But it
I have two columns in a view which give me date parts. They are
HI i have two date pickers. datepicker1, datepicker2. I need datepicker1.date to compare with
I have two dates: how do I compare which one is greater date in
I have a grid named 'GridView1' contains two columns 'Date' and 'Session Details' I
Hello i have two columns: duration (int) and dateCol (date) in a table. How
I have a SQL table with two columns Date and User and contains 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.