开发者

LSDateFormat is generating default date of 12/30/1899... how to fix?

One of our databases has a page set up to print reports containing various geol开发者_JAVA百科ogical 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! :)


Coldfusion 9 has a isNull() function that returns a boolean:

<cfif isNull(qLithHead.drill_date)> 

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0-3c4c0bb81223f1daffb-8000.html

Or, if you are not running CF9, you could try:

<cfif isDate(qLithHead.drill_date)>

or

<cfif Year(qLithHead.drill_date) EQ '1899'>

to get rid of the ugly timestamp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜