LSDateFormat 正在生成默认日期 12/30/1899...如何修复?
我们的一个数据库设置了一个页面来打印包含各种地质信息的报告。有问题的数据库是 FoxPro DB,并包含一个日期字段,在 FoxPro 中格式为 mm/dd/yy。
报告表单中有一段代码
#LSDateFormat(qLithHead.drill_date, "mm/dd/yyyy")#
,用于提取钻取日期并将其转换为请求的格式,在此过程中获取所有 1500 条没有钻取日期的记录并添加默认的 12/30/1899 日期。
老板不希望报告中包含默认日期,但希望报告中包含完整的格式化日期(如果存在),因为他们确实有一些可以追溯到 1900 年代初期的数据,并且需要列出完整的世纪。
我正在尝试编写一个 if/else 语句,该语句将创建一个变量 d_date,并存储
LSDateFormat(qLithHead.drill_date, "mm/dd/yyyy")
该字段是否已填充, 否则,如果日期为空,它将存储一个空字符串“”。
<cfif (EMPTY(qLithHead.drill_date))>
<cfset d_date=" ">
<cfelse>
<cfset d_date=#LSDateFormat(qLithHead.drill_date, "mm/dd/yyyy")#>
</cfif>
然后在报告的日期区域中,我将简单地调用 d_date 变量,无论其值是什么:
#d_date#
无论如何,这就是我想要完成的任务的总体思路。我完全不确定 CF 语法。
感谢您提供的任何帮助。
谢谢! :)
One of our databases has a page set up to print reports containing various geological information. The database in question is a FoxPro DB, and contains a date field which in FoxPro is formatted mm/dd/yy.
There is a snippet of code in the report form
#LSDateFormat(qLithHead.drill_date, "mm/dd/yyyy")#
which is pulling the drill_date and converting it to the requested format, and in the process is taking all 1500~ records with no drill date and adding the default 12/30/1899 date.
Boss doesn't want the default date in the reports, but wants the full, formatted date (when it exists) on the reports because they do have some data that goes back to the early 1900s and they need the full century listed.
I'm trying to write an if/else statement that will create a variable, d_date, and store
LSDateFormat(qLithHead.drill_date, "mm/dd/yyyy")
if the field is filled,
else it will store an empty string " " if the date is empty.
<cfif (EMPTY(qLithHead.drill_date))>
<cfset d_date=" ">
<cfelse>
<cfset d_date=#LSDateFormat(qLithHead.drill_date, "mm/dd/yyyy")#>
</cfif>
and then in the date area of the report I'll simply call the d_date variable, whatever its value:
#d_date#
In any case, that's the general idea of what I'm trying to accomplish. I'm not at all sure of the CF syntax.
Any help you can offer is appreciated.
Thanks! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Coldfusion 9 有一个 isNull() 函数,它返回一个布尔值:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0-3c4c0bb81223f1daffb-8000.html
或者,如果您没有运行 CF9,您可以尝试:
或
摆脱丑陋的时间戳
Coldfusion 9 has a isNull() function that returns a boolean:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0-3c4c0bb81223f1daffb-8000.html
Or, if you are not running CF9, you could try:
or
to get rid of the ugly timestamp