Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Test A Date? 1

Status
Not open for further replies.

scripter73

Programmer
Apr 18, 2001
421
US
Hi,

I have the following code that receives a "date" from a user in piecemeal. "MM" is a text box, "DD" is a text box, and "YYYY" is a text box.

In my Cold Fusion code, I create a session variable called #session.lossdate# that concatenates the three parms taken from the URL.

I want to verify that I do indeed have a date format of YYYYMMDD.

I've tried to do the IsDate(#session.lossdate#) function, but I think my syntax's coming up short. Can someone help me out? I want to find out if what I currently have is a date, and if not, how can I make it a date?

Code follows:


<html>
<head><title>Date Manipulation</title></head>
<body>
<cfset #session.lossdate# = '#url.lossdate_year##url.lossdate_month##url.lossdate_day#'>

<cfquery name=&quot;losslook&quot; datasource=&quot;wdata&quot;>
select wpol_policy_alpha,
wpol_policy_number,
wpol_renewal_seq_number,
wpol_endorsement_no,
wpol_eff_date,
wpol_exp_date,
wpol_endorse_date,
wpol_canc_eff_date,
wpol_rein_date
from PLWEBPOL02
where (wpol_policy_number = #session.policydigit#)
</cfquery>

Verify lossdate.<br>
Loss date is <cfoutput>#session.lossdate#</cfoutput>.
Is this viewed as a date? <cfoutput>IsDate(&quot;02/20/01&quot;)</cfoutput><br>
</body>
</html>


Thanks in advance,
scripter73

 
Does this help you?

First of all, you need to format the date with something like &quot;/&quot; as &quot;MM/DD/YY&quot;
<CFSET SESSION.lossdate = &quot;#URL.lossdate_month#/#URL.lossdate_day#/#URL.lossdate_year#&quot;>

<CFQUERY NAME=&quot;losslook&quot; DATASOURCE=&quot;wdata&quot;>
select wpol_policy_alpha,
wpol_policy_number,
wpol_renewal_seq_number,
wpol_endorsement_no,
wpol_eff_date,
wpol_exp_date,
wpol_endorse_date,
wpol_canc_eff_date,
wpol_rein_date
from PLWEBPOL02
where (wpol_policy_number = #session.policydigit#)
</CFQUERY>

<CFIF IsDate(SESSION.lossdate)>
Valid Date
<CFELSE>
Not Valid Date
</CFIF> - tleish
 
Thanks tleish!

I did what you suggested, and CF does recognize my session.lossdate as a date now. I have another question, though.

I'm going to be doing some additional processing with session.lossdate. I'm comparing it to another date variable from an AS/400 system. That date variable is in the following format Zoned*8.

Suppose I'm using a <cfquery> to get my AS/400 data variable wpol_eff_date. Can I say something like,
<cfif #session.lossdate# GT wpol_eff_date>...

I guess my main question here is am I still comparing apples to apples here?

Please advise and thanks for your great help.

scripter73
 
hi scripter73

Have you gotten the AS/400 system to pass the date? Is that part working? Can you output the date somewhere? Post the format here if you're still having trouble.

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top