Skip to main content
Inspiring
Dec 12, 2012 5:17 PM UTC
Question

invalid date

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 is closed to new replies. Start a new post to keep the conversation going.

5 replies

BKBK
Community Expert
Community Expert
Dec 13, 2012 6:32 PM UTC

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.

Translate
Inspiring
Dec 12, 2012 6:11 PM UTC

What is the datatype of the database field chgdate?

Translate
kt03Author
Inspiring
Dec 12, 2012 6:32 PM UTC

datetime

Translate
Inspiring
Dec 12, 2012 8:38 PM UTC

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.

Translate
Known Participant
Dec 12, 2012 5:17 PM UTC

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

Translate