Khurram Ijaz
Khurram Ijaz

Reputation: 1864

Get date out of sql server datetime

I need to get the date from a SQL Server datetime, and then format the date. (i.e. 01-Jan-2000) I'm using PHP.

currently, SQL is returning 2009-02-13 22:00:00.000.

Upvotes: 4

Views: 15211

Answers (3)

Hasan Sonet
Hasan Sonet

Reputation: 1

Add this to conncetionInfo => 'ReturnDatesAsStrings'=>true

$connectionInfo = array( "Database"=>"AdventureWorks", 'ReturnDatesAsStrings '=> true);

Upvotes: 0

pilotstarmedia.com
pilotstarmedia.com

Reputation: 577

You can pool date in any format you want directly from mySQL query,

SELECT DATE_FORMAT(column_name, '%d-%b-%Y') FROM tablename

Upvotes: 1

Dan Grossman
Dan Grossman

Reputation: 52372

echo date('d-M-Y', strtotime($datetime_from_db));

Upvotes: 15

Related Questions