Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Format date

  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    23
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Format date

    I currently have this

    Code:
    ("SELECT * FROM material WHERE status='$status' AND category='$category' ORDER BY `material`.`title` ASC ");
    Where do you stick this:

    Code:
     
    DATE_FORMAT(`date`,'%m/%d/%Y') AS showdate
    While still using *? Or do I have to name all of the columns?
    Last edited by tdprout; 10-16-2012 at 10:22 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    While you *should* name all the fields you want, it is not required. You can simply select the date format in combination with the *: SELECT *, DATE_FORMAT(`date`, '%m/%d/%Y') AS showdate. You'll still have the `date`, but also the `showdate` fields returned.

  • #3
    Regular Coder
    Join Date
    Oct 2012
    Location
    mother land --india
    Posts
    161
    Thanks
    37
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by tdprout View Post
    I currently have this

    Code:
    ("SELECT * FROM material WHERE status='$status' AND category='$category' ORDER BY `material`.`title` ASC ");
    Where do you stick this:

    Code:
     
    DATE_FORMAT(`date`,'%m/%d/%Y') AS showdate
    While still using *? Or do I have to name all of the columns?

    Hope below post will help you ....

    date Format code help while posting info in to mysql


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •