Lauren Quantrell wrote in message
<11**********************@z14g2000cwz.googlegroups .com> :
Roy,
Yes thanks. The problem seems to come when I store the date value in a
text field. That always has to be converted when refering to the text
fiield in a parameter:
.set prm = .createparameter("MyDate", addate, adparaminput)
.parameters.append prm
.prm.value = (Format(Me.StartDate, "m/d/yyyy hh:nn:ss AM/PM")
And also when using the InputParameters property of a property sheet:
@StartDate = Date()
does not work but:
Format(Date(), "m/d/yyyy hh:nn:ss AM/PM")
does work.
That I find strange!
I don't know about the other things, but here
.prm.value = (Format(Me.StartDate, "m/d/yyyy hh:nn:ss AM/PM")
you are effectively doing something like this
- take the contents of (presumably) a text control, which might
be a valid date
- format it to a STRING representation of that date in US date
- this is coerced/cast implicitly back to being a date when
assigned to the parameter
Doing stuff with dates seems to bring a lot of interresting
challenges. What I try to be carefull about, is keeping
dates as dates, and try to avoid formatting dates to strings
and back when assigning. When living in nondefault places,
thats often where the amusement starts;-)
I think I'd validate the contents of the text control, assign
to a date variable, perhaps, or directly to the parameter
without formatting between date and string.
If you wan't to use format, I think you'd need to
disambiguate it, use for instance the one Allen
Browne shows here
http://allenbrowne.com/ser-36.html
"mm\/dd\/yyyy ... or the one Lyle Fairfield presents,
elsethreads, but darned if I know what happens if you
let Access implicitly cast a string representation of an
US date to a variable of datatype date, when the system
on which it is run has it's "belief system" anchored to
UK regional settings, but I think it will create some
hillarius hours of debugging when both the day and
month are less than 13;-)
' try this with UK settings ...
dim dt1 as date
dim dt2 as date
dim dt3 as date
dt1 = #10/12/2005#
dt2 = fomat$(dt1, "m/d/yyyy")
dt3 = dt1
debug.print dt1, dt2, dt3
--
Roy-Vidar