php-db | 2001041
Date: 04/02/01
- Next message: Liz Bander: "[PHP-DB] display login info"
- Previous message: meiji <email protected>: "[PHP-DB] Solaris 2.6, PHP 4.0.4pl1, Solid EE 3.51"
- In reply to: Richard Quadling: "[PHP-DB] Getting a date from MS SQL in the correct format."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected>]
> Sent: Monday, April 02, 2001 12:10 PM
> To: php-db <email protected>
> 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 <email protected>
> For additional commands, e-mail: php-db-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
>
>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Liz Bander: "[PHP-DB] display login info"
- Previous message: meiji <email protected>: "[PHP-DB] Solaris 2.6, PHP 4.0.4pl1, Solid EE 3.51"
- In reply to: Richard Quadling: "[PHP-DB] Getting a date from MS SQL in the correct format."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

