openbd cfloop 超过一个日期
我正在尝试将我的网站从 CF8 转换为 openBD。 我的网站中有一个 cfloop,可以在某个日期范围内循环。
本质上,我想在日期范围(从和到)的每 2 周(步骤)向数据库中插入一条新记录,
我的循环如下所示...
<cfloop
from = "#form.startDate#"
to = "#form.endDate#"
index = "i"
step = "#theStep#"
>
这在 CF8 中完美运行,在 openBD 中,我收到此错误... 不支持数据:值 [11/05/09] 不是数字
有解决办法吗?
谢谢
I'm trying to convert my sites from CF8 to openBD. I have a cfloop in a site that loops over a date range.
In essence, I want to insert a new record into the db for every 2 weeks (step) of a date range (from and to)
my loop looks like this...
<cfloop
from = "#form.startDate#"
to = "#form.endDate#"
index = "i"
step = "#theStep#"
>
This works perfectly in CF8, in openBD, I get this error...
Data not supported: value [11/05/09] is not a number
Any ideas of a work around?
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的问题在于没有检查表单中不明确的区域设置相关日期字符串。
一个更强大的版本是这样的:
限制人们在表格中输入明确的日期格式(例如“yyyy-mm-dd”)将很有帮助。
“值不是数字”错误来自这样一个事实:即使您向循环提供日期,循环仍然会遍历数字。 然后,它使用这些日期的数字表示,但它们必须有效且易于理解才能正常工作。
Your problem lies in not checking for ambiguous locale dependent date strings from your FORM.
A more robust version would be this:
It would be helpful to restrict people to entering unambiguous date formats into the FORM, like "yyyy-mm-dd".
The "value is not a number" error comes from the fact that the loop still goes over numbers, even if you feed it dates. It uses a numerical representation of these dates then, but they must be valid and intelligible for that to work.
我看不到你的代码,但这是我的第一个建议:
HTH。
I can't see your code, but here's my first suggestion:
HTH.
正如 Ben 所说,您的代码不存在 - 您需要使用 101 010 图标为其创建代码块。
这是另一个应该有效的解决方案:
As Ben says, your code isn't there - you need to use the 101 010 icon to create a code block for it.
Here's another solution which should work: