Re: datetime insert/update problem
Posted in 1997
shashank wrote:
>
> Hi All,
>
> How to insert or update in a datetime column using datetime
> function??
>
> e.g. Have a table col1 datetime year to fraction(3).
>
> Want to insert 1. '12/12/97'
> 2. '12/12/97 00:00:00.0'
>
> How to do this using datetime functions. I tried setting
> DBTIME/DBDATE
> but didn't work.
Whether you are inserting strings or using the datetime functions to
convert the strings to a datetime before inserting you must follow
standard POSIX date string format, and you must expand the string to
the entire precision of the column into which it is to be inserted.
So for you YEAR TO FRACTION(3) the string must present
<year>-<month>-<day><space><hour>:<minute>:<second>.<3digits of
fraction> Thus:
insert into tab1(...,col1) values (...,"1997-12-12 00:00:00.000");
or in ESQL with the the dtcvasc function:
int ret;
EXEC SQL BEGIN DECLARE SECTION;
datetime year to fraction(3) dat;
...
EXEC SQL END DECLARE SECTION;
ret = dtcvasc( &dat, "1997-12-12 00:00:00.000" );
exec sql insert into tab1( ..., col1) values (..., :dat );
Art S. Kagel, kagel@bloomberg.com