Jump to content

Uk date format in select query


ianhaney

Recommended Posts

Hi

 

Sorry quick one, I am trying to make the date format into UK format and have entered the following into the SELECT query but is returning 0 results where as it should have two results

 

I have the following SQL query

$sql=$dbh->prepare("SELECT 
      e.emp_id
    , t.task_id
	, t.customer_name
	, t.customer_phone
	, t.customer_address
	, DATE FORMAT(t.date_of_repair,'%d/%m/%Y') AS date_of_repair
    , t.description 
    , t.status
    FROM employee e
    JOIN assignment a ON e.emp_id = a.emp_id
    JOIN task t ON a.task_id = t.task_id
    WHERE e.emp_id = ?");
$sql->execute(array($_SESSION['user']));
Link to comment
Share on other sites

No hard and fast rule. If all you want to do with date is display it then it doesn't really matter, though it's easier to to do it in the query.

 

If you need to do some further processing of the date in your PHP then select the raw date (yyyy-mm-dd) in the query, as d/m/y it useless for anything other than display.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.