Dates not behaving as expected


hello,

 

i using livecycle designer 8.05 , trying create field  users enter effective date ("txt_effdate" - 'date/time' field)  , end date ("txt_enddate" - 'date/time field) a  transaction, , if end date less 6 months start  date error message.

 

i used code below read  "txt_effdate" field , create field ("sixmos") that  displays date 6 months after start date:

// "sixmos" -  text field

var effdate = util.scand("mm/dd/yyyy",  txt_effdate.formattedvalue);
var sfullyear = effdate.getfullyear();
var  smonth = effdate.getmonth();
var sdate = effdate.getdate();
this.formattedvalue  = util.printd("mm/dd/yyyy", new date(sfullyear, (smonth + 6), sdate) );

 

the trouble  comes in when try compare end date "sixmos" date.  the  following code lets dates pass, meaning cannot recognize the  "txt_enddate" less "sixmos" date:

 

var aeffdate =  util.scand("mm/dd/yyyy", txt_effdate.formattedvalue);

if (aeffdate  < sixmos.rawvalue) {
xfa.host.messagebox("end date less 6  months start date, please make correction.", "end date issue");
                 }

 

i've  tried comparing "txt_effdate" directly "sixmos", various uses  of rawvalue , formattedvalue extensions.  i've tried  aeffdate.value instead of aeffdate... missing simple  here?

 

thanks  help!

yes missing fundamentals. comparing dates not easy subtracting 1 other. there functions provided can pass date , return number of milliseconds point in time (called epoch). when have both dates in format can subtract 2 , difference (in milliseconds). these functions easier use in formcalc javascript. have included couple of samples have use technique. start these , if need further not hesitate ask.

 

paul



More discussions in LiveCycle Designer


adobe

Comments

Popular posts from this blog

CS5 Adobe Media Encoder: Encode failed because the source duration is nil.

cf_sql_integer vs cf_sql_bigint vs cf_sql_int??

localhost/joomla15/administrator doesnt work - Joomla! Forum - community, help and support