🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Store datetime field as String

#806
From: Svein Erling Tysvær
Date: Thu, 10 May 2007 11:45
39 lines
1939 bytes
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: <464305c9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!feed10.multikabel.net!multikabel.net!feed20.multikabel.net!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4640605c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,d8456dd5bcafd5a4
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 10 May 2007 13:45:13 +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>
In-Reply-To: <4640605c@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 84.49.7.130
Message-ID: <464305c9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1178797513 84.49.7.130 (10 May 2007 04:45:13 -0700)
Lines: 39
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!feed10.multikabel.net!multikabel.net!feed20.multikabel.net!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail