Board index » delphi » Passing TDateTime as a parameter

Passing TDateTime as a parameter

Hi,

What is the best (safest) way to pass a TDateTime value as a parameter. The
method I am using now is
AdoCommand.Parameters[0].Value:=DateTimeToStr(MyDateTimeVal) but I don't
think this would be safe for all regions.

I suspect this is causing problems with my dates being logged as dd/mm/yyyy
format in Australia for example, where they should be mm/dd/yyyy.

--
dj-c

 

Re:Passing TDateTime as a parameter


AdoCommand.Parameters[0].AsdateTime := MyDateTimeVal
will work on any computer

--
With best regards, Mike Shkolnik
EMail: mshkol...@scalabium.com
http://www.scalabium.com

"dj-c" <ne...@mind.com> ???Y/???Y ????? ???Y??:
news:3edca08f$1@newsgroups.borland.com...

Quote
> Hi,

> What is the best (safest) way to pass a TDateTime value as a parameter.
The
> method I am using now is
> AdoCommand.Parameters[0].Value:=DateTimeToStr(MyDateTimeVal) but I don't
> think this would be safe for all regions.

> I suspect this is causing problems with my dates being logged as
dd/mm/yyyy
> format in Australia for example, where they should be mm/dd/yyyy.

> --
> dj-c

Re:Passing TDateTime as a parameter


I don't know how I would define best, but one way would be to set the
parameter type as a date-time and then pass the value directly and let
it handle the conversion if needed.
Quote
dj-c wrote:
> Hi,

> What is the best (safest) way to pass a TDateTime value as a parameter. The
> method I am using now is
> AdoCommand.Parameters[0].Value:=DateTimeToStr(MyDateTimeVal)

Re:Passing TDateTime as a parameter


Quote
"Mike Shkolnik" <mshkolnik2...@ukr.net> wrote in message

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

Quote
> AdoCommand.Parameters[0].AsdateTime := MyDateTimeVal
> will work on any computer

I don't have the AsDateTime property on the TParameter object. I'm using D5
if that makes any difference.

--
dj-c

Re:Passing TDateTime as a parameter


Quote
"Richard Gilbert" <rag...@bellsouth.net> wrote in message

news:3EDCA3C8.5040307@bellsouth.net...

Quote
> I don't know how I would define best, but one way would be to set the
> parameter type as a date-time and then pass the value directly and let
> it handle the conversion if needed.

Would it be safe to use Parameters[0].Value:=MyDateTime or is this
considered ambigous? It seems to work but I remember when I first tried this
a few months ago I ran into a problem (which I cant seem to reproduce now).
Does setting the parameter type a difference if it is in fact working now?

--
dj-c

Re:Passing TDateTime as a parameter


Quote
>AdoCommand.Parameters[0].Value:=DateTimeToStr(MyDateTimeVal) but I don't
>think this would be safe for all regions.

Make sure the parameter.dataType is ftDateTime then use
AdoCommand.Parameters[0].Value:= MyDateTimeVal;
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads