RE: [PHP-DB] Getting a date from MS SQL in the correct format.

From: Date: Mon, 02 Apr 2001 16:24:49 +0000
Subject: RE: [PHP-DB] Getting a date from MS SQL in the correct format.
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8147@lists.php.net to get a copy of this message
Richard, ODBC provides escape syntax to specify what how dates are returned from the database: e.g. Select * from Table where Date = {d '2000-11-17'} Best regards, Andrew -------------------------------------- Andrew Hill - OpenLink Software Director Technology Evangelism eBusiness Infrastructure Technology http://www.openlinksw.com > -----Original Message----- > From: Richard Quadling [mailto:richard.quadling@carval.co.uk] > Sent: Monday, April 02, 2001 12:10 PM > To: php-db@lists.php.net > Subject: [PHP-DB] Getting a date from MS SQL in the correct format. > > > I want to extract a date from a datetime field in Microsoft SQL, via ODBC > ('cause we support different databases, or so I'm told, and hey, what do I > know!!!!! <grrrrr!>). > > I want the format to be CCYYMMDD. > > Is there a MS SQL function for this? > > I've found DATEPART("YYYY",field), but I don't know how to get > all the bits > (i.e. YYYY, MM, DD). I get a numerical addition. > > If I CAST as varchar, I don't get a 0 for <10 on MM and DD. > i.e. 1st January 2001 comes out as 200111 rather than 20010101 > > I know there must be a format function, but SQL novice here can't find it. > > Any suggestions. In the mean time, I've had to use DATEPART to pull the > three bits in separately and add a bit to the PHP templates to > add them all > together. Ideally I want just the value as CCYYMMDD. > > Regards, > > Richard Quadling. > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#8147) next »