🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #807

Re: Store datetime field as String

#807
From: Svein Erling Tysvær
Date: Thu, 10 May 2007 11:47
59 lines
2545 bytes
Sorry, a small mistake (char should be 4 characters):

Update table set somefield =
   case
     when extract(day from current_date) < 10 then
       '0' || extract(day from current_date)
     else extract(day from current_date)
   end ||'/'
   case
     when extract(month from current_date) < 10 then
       '0' || extract(month from current_date)
     else extract(month from current_date)
   end ||'/'
   substring(cast(extract(year from current_date) as char(4))
             from 3 for 2)
where
<condition>

Svein Erling Tysv�r wrote:
> Try something like
> 
> Update table set somefield =
>   case
>     when extract(day from current_date) < 10 then
>       '0' || extract(day from current_date)
>     else extract(day from current_date)
>   end ||'/'
>   case
>     when extract(month from current_date) < 10 then
>       '0' || extract(month from current_date)
>     else extract(month from current_date)
>   end ||'/'
>   substring(cast(extract(year from current_date) as char(2)) from 3 for 2)
> where
> <condition>
> 
> The syntax may or may not be different in InterBase.
> 
> HTH,
> Set
> 
> 
> Craig Cookesley wrote:
>> Hi
>>
>> I need to update a field defined as varchar(8) with a datetime field 
>> in a trigger
>>
>> The field is used extensive in code so to change the field type would 
>> be a big job
>>
>> i was hoping to cast or convert the datatime field to string before 
>> update
>>
>> Any ideas would be appreciated
>>
>> Thanks in advance
>>
>> Craig 
Technical Details
Message-ID: <4643064e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!nx01.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4640605c@newsgroups.borland.com> <464305c9$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,d8456dd5bcafd5a4
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII
Date: Thu, 10 May 2007 13:47:26 +0200
From: Svein Erling Tysvær
 <svein.erling.tysvaer@kreftregisteret.no>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Re: Store datetime field as String
References: <4640605c@newsgroups.borland.com> <464305c9$1@newsgroups.borland.com>
In-Reply-To: <464305c9$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 84.49.7.130
Message-ID: <4643064e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1178797646 84.49.7.130 (10 May 2007 04:47:26 -0700)
Lines: 59
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!nx01.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail