Skip to main content
Inspiring
December 12, 2012
Question

invalid date

  • December 12, 2012
  • 3 replies
  • 1221 views

Hi,

I am query out and display all dates from my table but for some reason I have invalide date such as :1753-01-01 00:00:00.0 and some others invalid.

I only need to display the valid date, if not valid then display empty, however, the code i have below was not working.

<cfloop query="q_pur">

   <cfif not isDate(chgDate)>

   <cfset valid_chg_date = '' />

   <cfelse>

   <cfset valid_chg_date = chgDate />

   </cfif>

   #valid_chg_date#<br /> :--->it still shows 1753-01-01 00:00:00.0 instead of ' ' (empty string)

</cfoutput>

any idea?

thanks

This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
December 13, 2012

kt03 wrote:

Hi,

I am query out and display all dates from my table but for some reason I have invalide date such as :1753-01-01 00:00:00.0 and some others invalid.

I only need to display the valid date, if not valid then display empty, however, the code i have below was not working.

<cfloop query="q_pur">

   <cfif not isDate(chgDate)>

   <cfset valid_chg_date = '' />

   <cfelse>

   <cfset valid_chg_date = chgDate />

   </cfif>

   #valid_chg_date#<br /> :--->it still shows 1753-01-01 00:00:00.0 instead of ' ' (empty string)

</cfoutput>

ColdFusion is showing you that because the string 1753-01-01 00:00:00.0 represents a valid  date.

Inspiring
December 12, 2012

What is the datatype of the database field chgdate?

kt03Author
Inspiring
December 12, 2012

datetime

Inspiring
December 12, 2012

The ColdFusion isDate() function takes a string argument, attempts to parse it to a date, and returns either true or false depending on the result.  Running it on something that is already a datetime doesn't make any sense.

Known Participant
December 12, 2012

Greetings,

I will be out of the office the morning of Wednesday December 12, returning by 2:00pm EST. I will answer all emails as soon as I return. For emergencies only, please contact Rob Panico at rpanico@altsystem.com.

Thanks,

Ron Barth

Alternative Systems

www.altsystem.com

603.537.9473