Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to insert milliseconds to sql server

147 views
Skip to first unread message

Ganesh

unread,
Jul 17, 2003, 8:40:31 AM7/17/03
to
Hi there,

here the string '14/07/03 23:57:37.506'

i'd like to insert into a datetime field in sql server with milliseconds,
how to do this

i've to use like this

Table1.Insert
Table1.FieldByName('logdate').AsString := datestring;
Table1.Post;

it works but not inserting millseconds how to do this

thanks


gc

unread,
Jul 17, 2003, 9:04:02 AM7/17/03
to
Check out FormatDateTime in Delphi help. In the mean time, it goes
something like this:

Table1.FieldByName('logdate').AsString := FormateDateTime('dd/mm/yyyy
hh:nn:zzz', dtDateValue);

where dtDateValue is a TDateTime.This will give date values with the format:
01/04/2003 22:25:1043 (for example)

Hope this helps

Gord

"Ganesh" <gsga...@yahoo.com> wrote in message
news:3f1699bf$1...@newsgroups.borland.com...

Ganesh

unread,
Jul 17, 2003, 9:05:13 AM7/17/03
to
'14/07/03 23:57:37.506'

No still having problem

even i tried

Table1.Insert
Table1.FieldByName('logdate').AsString := '14/07/03 23:57:37.506';
Table1.Post;

but not inserting milli seconds

"Henrik Bruhn" <H.B...@WIDEX.DK> wrote in message
news:3f169db1$1...@newsgroups.borland.com...


> > i'd like to insert into a datetime field in sql server with
milliseconds,
> > here the string '14/07/03 23:57:37.506'
>

> Delphi and Windows apparently do not support milliseconds in the DateTime
> formats.
> But you can use: DateTimetoStr(T) + '.' + IntToStr(MilliSecondOf(T))
>
> Henrik
>
>


Henrik Bruhn

unread,
Jul 17, 2003, 8:59:28 AM7/17/03
to
> i'd like to insert into a datetime field in sql server with milliseconds,
> here the string '14/07/03 23:57:37.506'

Delphi and Windows apparently do not support milliseconds in the DateTime

John Herbster (TeamB)

unread,
Jul 17, 2003, 9:25:38 AM7/17/03
to

"Henrik Bruhn" <H.B...@WIDEX.DK> wrote

> Delphi and Windows apparently do not support
> milliseconds in the DateTime formats.

Henrik, The Delphi TDateTime variable type *does*
support a resolution of milliseconds. What other
aspect of Delphi and Windows might you be referring
to. Rgds, JohnH


John Leavey

unread,
Jul 17, 2003, 9:54:30 AM7/17/03
to
On Thu, 17 Jul 2003 13:40:31 +0100, "Ganesh" <gsga...@yahoo.com> wrote:

>Hi there,
>
>here the string '14/07/03 23:57:37.506'
>
>i'd like to insert into a datetime field in sql server with milliseconds,
>how to do this
>
>i've to use like this
>
>Table1.Insert
>Table1.FieldByName('logdate').AsString := datestring;
>Table1.Post;

If you have the various elements of the date and time as numeric values, you can use

Table1.FieldByName('logdate').Value := EncodeDate( ... ) + EncodeTime( ... );


John Leavey

Henrik Bruhn

unread,
Jul 17, 2003, 10:07:30 AM7/17/03
to
>> The Delphi TDateTime variable type *does* support a resolution of
milliseconds.
>>What other aspect of Delphi and Windows might you be referring

John

I was referring to the conversion of TDateTime to string and was not aware
of the 'z' specifier.

PS: Thanks to Gord (GC) for the information

Henrik


gc

unread,
Jul 17, 2003, 10:14:29 AM7/17/03
to
No problemo! Glad to help. I don't know much, but I know what I know ;)


"Henrik Bruhn" <H.B...@WIDEX.DK> wrote in message

news:3f16...@newsgroups.borland.com...

Sujit Singhania

unread,
Jul 17, 2003, 10:52:39 AM7/17/03
to
Ganesh,

I have read somewhere that BDE does not supports milliseconds in DateTime
fields.

It is better to post your question in b.p.bde where you can expect a
reasonable answer.

Sujit


"Ganesh" <gsga...@yahoo.com> wrote in message
news:3f1699bf$1...@newsgroups.borland.com...

Mike Manning

unread,
Jul 18, 2003, 8:02:42 AM7/18/03
to
Or.. if you don't mind using a SQL update script, why not:

a) convert the datetime to a decimal with 10 decimal places
b) use a update or insert script - eg 'Update table1 set logdate =
37816.9983507639 where ...(identify row etc)'

Mike


"Ganesh" <gsga...@yahoo.com> wrote in message
news:3f1699bf$1...@newsgroups.borland.com...

0 new messages