使用Intl日期格式时的日期参数 [英] Date Parameter when using Intl Date Formats

查看:117
本文介绍了使用Intl日期格式时的日期参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经想出了(困难的方法)我需要在执行我的存储过程之前将所有日期

参数转换为美国格式,其中

日期用作参数。

(格式(StartDate," m / d / yyyy hh:nn:ss AM / PM")


至少我以为我做到了!


然后我发现如果我使用以下结构,日期

不需要首先格式化为美国:


Dim StartDate as Date,EndDate as Date


StartDate = Date()

EndDate = Date()+1


cmd.Execute,参数:= Array(StartDate,EndDate),

选项:= adExecuteNoRecords


我是吸烟的吗?在这里或者我们的MS朋友让这个更加令人困惑

不必要吗?

I already figured out (the hard way) I need to convert all my date
parameters into USA format before executing my stored procedures where
dates are used as parameters.
(Format(StartDate, "m/d/yyyy hh:nn:ss AM/PM")

At least I thought I did!

But then I discover that if I use the following construction, the dates
do not need to be formatted to USA first:

Dim StartDate as Date, EndDate as Date

StartDate = Date()
EndDate = Date() +1

cmd.Execute , Parameters:=Array(StartDate, EndDate),
Options:=adExecuteNoRecords

Am I smoking dope here or did our MS friends make this more confusing
than necessary?

推荐答案

Lauren Quantrell写道消息

< 11 ********************* @ o13g2000cwo.googlegroups.com>:
Lauren Quantrell wrote in message
<11*********************@o13g2000cwo.googlegroups. com> :
我已经想出了(困难的方法)我需要在执行我的存储过程之前将所有日期
参数转换为美国格式,其中
日期用作参数。
(格式(StartDate) ,m / d / yyyy hh:nn:ss AM / PM)

至少我以为我做过了!

然后我发现如果我使用了在构建之后,日期
不需要首先格式化为USA:

将Date StartDate作为Date,EndDate作为Date

StartDate = Date()
EndDate = Date()+1

cmd.Execute,参数:= Array(StartDate,EndDate),
选项:= adExecuteNoRecords

我吸烟吗麻烦在这里或我们的MS朋友让这更加混乱
而不是必要吗?
I already figured out (the hard way) I need to convert all my date
parameters into USA format before executing my stored procedures where
dates are used as parameters.
(Format(StartDate, "m/d/yyyy hh:nn:ss AM/PM")

At least I thought I did!

But then I discover that if I use the following construction, the dates
do not need to be formatted to USA first:

Dim StartDate as Date, EndDate as Date

StartDate = Date()
EndDate = Date() +1

cmd.Execute , Parameters:=Array(StartDate, EndDate),
Options:=adExecuteNoRecords

Am I smoking dope here or did our MS friends make this more confusing
than necessary?




连接一些动态之间有点区别

sql STRING,你需要用足够的

信息来舀取它以正确评估传递的STRING,

和传递参数特定/指定数据类型的后缀。


后者可能与在相同数据类型的

变量之间分配值相当。

somedate = somotherdate


这些方法可以更轻松地处理单引号

的文本参数和其他特殊字符。


我会更经常做一些像


with cmd

...

.set prm = .createparameter(" MyDate",addate,adparaminput)

.parameters.append prm

prm.value = dtMyDate

...


-

Roy-Vidar



There''s a bit of difference between concatenating some dynamic
sql STRING, where you''ll need to spoonfeed it with enough
information to make correct assessement of the passed STRING,
and passing parameters of a specific/specified datatype.

The latter, is perhaps comparable to assigning values between
variables of the same datatype

somedate = somotherdate

Those methods makes it a bit easier to deal with single quotes
for text parametes and other special characters, too.

I''ll more often do something like

with cmd
...
.set prm = .createparameter("MyDate", addate, adparaminput)
.parameters.append prm
prm.value = dtMyDate
...

--
Roy-Vidar


罗伊,

谢谢。当我将日期值存储在

文本字段中时,似乎会出现问题。当在参数中引用文本

fiield时,总是必须进行转换:


.set prm = .createparameter(" MyDate",addate, adparaminput)

.parameters.append prm

.prm.value =(格式(Me.StartDate," m / d / yyyy hh:nn:ss AM / PM" ;)


当使用属性表的InputParameters属性时:


@StartDate = Date()


不起作用但是:


格式(日期(),m / d / yyyy hh:nn:ss AM / PM)


确实有用。


我觉得很奇怪!

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!


Lauren Quantrell写道:


yyyy-mm-dd hh:nn:ss


总是有效


它还有一个额外的好处,就是在文明(文明=非盎格鲁)世界中被接受的符号。

Lauren Quantrell wrote:

yyyy-mm-dd hh:nn:ss

always works

It has the added advantage of being the accepted notation in the
civilized (civilized=non Anglo) world.


这篇关于使用Intl日期格式时的日期参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆