Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

invalid date

Explorer ,
Dec 12, 2012 Dec 12, 2012

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

TOPICS
Getting started
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 12, 2012 Dec 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 12, 2012 Dec 12, 2012

What is the datatype of the database field chgdate?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 12, 2012 Dec 12, 2012

datetime

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 12, 2012 Dec 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2012 Dec 13, 2012
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources