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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:21:26+00:00 2026-06-17T16:21:26+00:00

A mysql query is returning unexpected. I’m trying to concatenate a few strings containing

  • 0

A mysql query is returning unexpected. I’m trying to concatenate a few strings containing date queries like so:

mysql> select month(timestamp) +'-'+ day(timestamp) + '-' + 
       year(timestamp) as date FROM table ORDER BY timestamp DESC LIMIT 1;

and I’m getting a 4 digit result, which I assume is the sum of the expected result:

+------+
| date |
+------+
| 2035 |
+------+

I’ve also tried casting each one as CHAR which didn’t work:

mysql> select CAST(month(timestamp) as CHAR) +'-'+ CAST(day(timestamp) as CHAR) + '-' + 
CAST(year(timestamp) as CHAR) as date FROM table ORDER BY timestamp DESC LIMIT 1;

Could someone let me know what I’m doing wrong? … and I guess how to fix it would be nice too 🙂

  • 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-17T16:21:27+00:00Added an answer on June 17, 2026 at 4:21 pm

    In MySQL, use CONCAT_WS

    CONCAT_WS('-', month(timestamp),day(timestamp),year(timestamp))
    

    query,

    SELECT CONCAT_WS('-', month(timestamp),day(timestamp),year(timestamp)) AS DATE
    FROM   tablename
    ORDER  BY timestamp DESC 
    LIMIT  1
    

    or use DATE_FORMAT

    SELECT DATE_FORMAT(timestamp, '%m-%d-%Y') AS DATE
    FROM   Table1
    ORDER  BY timestamp DESC 
    LIMIT  1
    
    • SQLFiddle Demo

    Other(s):

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

Sidebar

Related Questions

I am trying to build complex mysql query but its returning wrong results... SELECT
Consider this simple MySQL query: SELECT CHAR(224 USING UTF8) This isn't returning anything for
I have the following MySQL query: SELECT SUM(IF(num_content>3,3,num_content)) FROM ( SELECT DATE(FROM_UNIXTIME(content_timestamp)) as dt,
I am trying to execute a sql query in Mysql query browser select *
A simple MySQL query is returning a result set that is missing results. SELECT
I'm trying to come up with a MySQL query to select the last record
So I have this awesome MySQL query that's returning me an awesome array >
I am returning query results from MySQL and I need to append them to
Mysql query returns result like this collector amount name 1 0.00 gihan 1 2000.00
this is the mysql query SELECT * FROM users AS up JOIN users AS

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.