🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Store datetime field as String

#796
From: Quinn Wildman (CodeGear Develope...
Date: Tue, 08 May 2007 16:29
28 lines
1850 bytes
Wayne has the best answer here. However, it should be noted that if you 
assign a date or timestamp to a string, it will be automatically casted 
as a string. Simple example:

create table foo (f1 varchar(10));
insert into foo values (current_date);

Wayne Niddery [TeamB] wrote:
> Craig Cookesley wrote:
>> 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
> 
> Use cast.
> 
> Update table set somefield = cast(current_date as varchar(8)) where 
> <condition>
> 
> 

-- 
CREATE DOMAIN NEW_COMPANY AS CHAR(8) DEFAULT 'CODEGEAR' CHECK (VALUE <> 
'BORLAND') NOT NULL;
Technical Details
Message-ID: <4640a4e1$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4640605c@newsgroups.borland.com> <464088c2@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: Tue, 08 May 2007 09:29:13 -0700
From: "Quinn Wildman (CodeGear Developer Support)" <qwildman@nospam.codegear.com>
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> <464088c2@newsgroups.borland.com>
In-Reply-To: <464088c2@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 10.143.19.108
Message-ID: <4640a4e1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1178641633 10.143.19.108 (8 May 2007 09:27:13 -0700)
Lines: 28
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail