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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:00:47+00:00 2026-06-17T22:00:47+00:00

I am building the following Query but am having syntax problems: SELECT FORMAT(yrs_served *

  • 0

I am building the following Query but am having syntax problems:

SELECT FORMAT(yrs_served * 365, 0) AS days_served,
ADDDATE(date_comm, INTERVAL days_served DAY(DATE_FORMAT(CONCAT_WS('-', yr_comm, mth_comm, day_comm), %Y-%m-%d) AS date_comm) AS left_office
FROM prime_minister JOIN ministry
;

As can been seen, I am first trying to CONCAT_WS three values into a date, then format it as a date with DATE_FORMAT, so that I can then use ADDDATE to add a number of days to this date.

Please advise where I am going wrong, thank you!

  • 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-17T22:00:48+00:00Added an answer on June 17, 2026 at 10:00 pm

    you cannot use ALIAS on the same level it has been define.

    SELECT   FORMAT(yrs_served * 365, 0) AS days_served,
             ADDDATE(CONCAT_WS('-', yr_comm, mth_comm, day_comm), INTERVAL (yrs_served * 365) DAY) AS left_office
    FROM     prime_minister JOIN ministry.....
    

    if you wan’t to use it, you just wrap it in a subquery, eg

    SELECT  days_served,
            ADDDATE(date_comm, INTERVAL days_served DAY) AS left_office
    FROM
    (
        SELECT  FORMAT(yrs_served * 365, 0) AS days_served,
                CONCAT_WS('-', yr_comm, mth_comm, day_comm) as date_comm
        FROM     prime_minister JOIN ministry.....
    ) s
    
    • ADDDATE (same with DATE_ADD)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following the documentation with an up to date automake (v1.12) but building still
I'm having trouble with the following code: start_date = dt.datetime(2012,01,01,00,00,00) end_date = dt.datetime(2014,01,01,00,00,00) sql=SELECT
Okay, I am building a VB.NET system but I'm having troubles in catching an
I'm building a MySQL query but I can't seem to get it right. I
I need help building a mysql query to select from multiple tables. I have
I'm building a ecommerce application with MySQL, but I'm having a hard time coming
I'm building an application in web.py, but am having some trouble when it comes
I have the following query: select mb.id as meter_id ,ds.mydate as mydate ,mb.name as
I'm building a dynamic query in my ASP.NET MVC project by the following: Dim
I'm having some trouble with finding the right syntax to accomplish the following: Is

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.