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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:22:27+00:00 2026-06-12T11:22:27+00:00

Possible Duplicate: MySQL date format i have this date which i need to make

  • 0

Possible Duplicate:
MySQL date format

i have this date which i need to make a comparison but i need to do it since the query!

Now i have this query:

Select date WHERE date="$today"

Where $todayis in this format :dmY
how can i directly transform it into dmY aswell? the date field?
Something like:

Select date("dmY",date) WHERE date="$today"

I don’t know if this is even possible to do, but i guess it might be, so i’d appreciate a little help even if it’s simply, yes, it’s doable, no, it’s not!

  • 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-12T11:22:28+00:00Added an answer on June 12, 2026 at 11:22 am

    I think where you are having issues is formating the php date to fit with what is been formated from your mysql_query

    Here’s what i came up with.

    I have created a simple code for you to handle this.

    The Procedure is that i got today’s date from mysql using CURDATE() function of mysql and then format it and match the exisiting column on the table

    MYSQL DATABASE

        -- phpMyAdmin SQL Dump
    -- version 3.4.5
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Oct 04, 2012 at 01:44 PM
    -- Server version: 5.5.16
    -- PHP Version: 5.3.8
    
    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    SET time_zone = "+00:00";
    
    --
    -- Database: `my_db`
    --
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `datetable`
    --
    
    CREATE TABLE IF NOT EXISTS `datetable` (
      `dateid` int(2) NOT NULL AUTO_INCREMENT,
      `datestuff` date NOT NULL,
      PRIMARY KEY (`dateid`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
    
    --
    -- Dumping data for table `datetable`
    --
    
    INSERT INTO `datetable` (`dateid`, `datestuff`) VALUES
    (1, '2012-10-02'),
    (2, '2012-10-04');
    

    PHP CODE (FILE)

       <?php
    //Connect to your host
    $con = mysql_connect("localhost","admin","admin");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    //select your database
    mysql_select_db("my_db", $con);
    
    //getting today's date and formating it, output is like this (4-10-2012)
    $today = date('j-m-Y');
    
    //query your table, also date has been formated like this (4-10-2012)
    $result = mysql_query("SELECT DATE_FORMAT( CURDATE( ) ,  '%e-%m-%Y' ) AS today, DATE_FORMAT( datestuff,  '%e-%m-%Y' ) AS datestuff FROM datetable WHERE CURDATE( ) = datestuff");
    
    //get the resultset
    while($row = mysql_fetch_array($result))
      {
      echo "date in table: ".$row['datestuff']. "---- today's date: ". $row['datestuff'];
      echo "<br />";
      }
    ?>
    

    Try it out let me know if it worked out for you….

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

Sidebar

Related Questions

Possible Duplicate: Format mysql datetime with php Well.. I have stored date(c) in Mysql
Possible Duplicate: php/Mysql query with inserting date fails I have a datepicker code below:
Possible Duplicate: PHP/MySQL - Format date/time I have input field (name:day1 and varchar) to
Possible Duplicate: php date compare PHP compare dates I have this code which permits
Possible Duplicate: MySQL: Large VARCHAR vs. TEXT? Since VARCHAR can have 65k bytes now,
Possible Duplicate: how to use DATE FORMAT in my query? I have a date
Possible Duplicate: Datetime vs Timestamp? I have a Mysql table, which has a column
Possible Duplicate: Converting string to MySQL timestamp format in php Given a date in
Possible Duplicate: MySQL query using an array Passing an array to mysql I have
Possible Duplicate: PHP: convert date format yyyy-mm-dd => dd-mm-yyyy [NOT IN SQL] Right now

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.