🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.vdbase.data.sql
Article #226

Re: converting dates to string

#226
From: Ivar B. Jessen
Date: Mon, 11 Jan 1999 00:00
28 lines
1764 bytes
On Mon, 11 Jan 1999 11:12:55 +0800, "Geoff S. Wass" <gswass@ibm.net>
wrote:

>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.
>
In thread 'Date' Steve Koterski replied on 15-12-98 as quoted below.

Ivar B. Jessen

>SELECT CAST(EXTRACT(YEAR FROM Data) AS CHAR(4)) ||
>  SUBSTRING(CAST((EXTRACT(MONTH FROM Data) + 100) AS CHAR(3)) FROM 2 FOR 2)

>  ||
>  SUBSTRING(CAST((EXTRACT(DAY FROM Data) + 100) AS CHAR(3)) FROM 2 FOR 2) 
>  || Name
>FROM "cont1998.dbf"

>Note that there is a little extra manipulation in here. Specifically,
>adding 100 to the extracted MONTH and DAY values and use of the SUBSTRING
>function. This is because of the way local SQL handles single-digit month
>and day values: it does not left-pad the values with a zero. Because of
>this, 1/20/1998 would come out as 1998120. By adding 100 to the extracted
>MONTH and DAY values and then retrieving the last two digits with
>SUBSTRING, that date would instead be translated as 19980120. This is more
>in keeping with the format of dates after using the dBASE function DTOS.
Technical Details
Message-ID: <369a0e61.6981540@forums.inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3699120D.76142F68@trautwein.com> <36996C37.BBD39384@ibm.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ff5a1,374a1c05f0f1b280
X-Google-Attributes: gidff5a1,public
From: ccc34145@vip.cybercity.dk (Ivar B. Jessen)
Subject: Re: converting dates to string
Date: 1999/01/11
Message-ID: <369a0e61.6981540@forums.inprise.com>
X-Deja-AN: 431251823
References: <3699120D.76142F68@trautwein.com> <36996C37.BBD39384@ibm.net>
Organization: Another Netscape Collabra Server User
Reply-To: bergishagen@it.dk
Newsgroups: borland.public.vdbase.data.sql