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.


Richard Quadling.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to