Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
What is the datatype of the database field chgdate?
Copy link to clipboard
Copied
datetime
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more