Article View: borland.public.vdbase.data.sql
Article #221Re: converting dates to string
From: Geoff S. Wass
Date: Mon, 11 Jan 1999 00:00
Date: Mon, 11 Jan 1999 00:00
31 lines
1603 bytes
1603 bytes
Thomas, I assume your data is in dBASE tables. It should be like this: SELECT field1, field2, CAST( dateField AS CHAR( 10 ) ) FROM yourTable I, however, found that the resulting dates have 2 digits only for the year (YY) instead of 4 (YYYY). I am not sure how to get around that unless you do something much longer like this: SELECT field1, field2, CAST( EXTRACT( YEAR FROM dateField ) AS CHAR( 4 ) ) || CAST( EXTRACT( MONTH FROM dateField ) AS CHAR( 2 ) ) || CAST( EXTRACT( DAY FROM dateField ) AS CHAR( 2 ) ) FROM yourTable This results in YYYYMMDD, except that single digit MMs or DDs have no leading zero (so, for example, 9 December 1998 comes out as 1998129 and not 19981209). There is a way to do that, too, but I don't have an SQL reference at hand. Failing all that, you could use the dBASE calculated field instead of these SQL calculated fields. See the online help for CLASS FIELD on how to do that. -- Geoff Wass Kuala Lumpur, Malaysia =>=> More dBASE info at http://members.theglobe.com/Geoff_Wass <=<=
Technical Details
Message-ID:
<36996C37.BBD39384@ibm.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3699120D.76142F68@trautwein.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ff5a1,374a1c05f0f1b280 X-Google-Attributes: gidff5a1,public From: "Geoff S. Wass" <gswass@ibm.net> Subject: Re: converting dates to string Date: 1999/01/11 Message-ID: <36996C37.BBD39384@ibm.net> X-Deja-AN: 431098339 Content-Transfer-Encoding: 7bit References: <3699120D.76142F68@trautwein.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Noordindarus Consultancy Sdn. Bhd. Mime-Version: 1.0 Newsgroups: borland.public.vdbase.data.sql