11-17-2011 05:45 PM
Does anyone have a simple method for computing date differance?
Websphere 5.11
Oracle 9i
RequestCenter 2006.7
Is there a simplier method to determine the difference between two dates?
I have tried using java based formulas, but they do not take into account months with 28 or 30 days.
I was hoping that there is a SIMPLE built in function
example:
serviceForm.Dictionary.Field2.getValue() - serviceForm.Dictionary.Field1.getValue()
any ideas?
thank you
Daniel
Safeway Inc.
11-17-2011 05:45 PM
You should use Javascript Date objects to do the calculation. Try this (I haven't tested it entirely):
var dateStart = new Date(serviceForm.Dictionary.Field1.getValue()[0]);
var dateEnd = new Date(serviceForm.Dictionary.Field2.getValue()[0]);
var dateDiffms = dateEnd - dateStart; // Difference in milliseconds
var dateDiffDays = dateDiffms / (1000 * 60 * 60 * 24);
In both Java and JavaScript (and other non-mainframe languages) a date value is the number of millseconds since Januar
11-17-2011 05:45 PM
Keep in mind, these scripts usually dont take in cosideration weekends and holidays, etc., as you probably want business days only.
Also a user's date format preference might break your script. I will see if I can find one of my old ones....
11-17-2011 05:45 PM
One slight change. The Date object also carries a time value, which you may want to ensure is 00:00:00.
dateStart.setHours(0,0,0,0);
dateEnd.setHours(0,0,0,0);
If you want to know more about these objects and their methods, visit www.w3schools.com/js/
Mark
11-17-2011 05:45 PM
This should work just fine. As a tweak for slightly faster math try this for the following line:
var dateDiffDays = dateDiffms / (1000 * 60 * 60 * 24);
try
var dateDiffDays = Math.round(dateDiffms/86400000); //(1000*60*60*24)
Then you can evaluate dateDiffDays
for how many days there are between your two dates.
11-17-2011 05:45 PM
"function Q3013_DataCallback(retArray, querylist)
{
if(retArray['Q3013.SHORTDATE']!=undefined)
{
if (retArray['Q3013.SHORTDATE'][0].toUpperCase() != 'MM/DD/YYYY')
{
alert('To Order This Service, You must change the Short Date Preference in your Service Catalog profile back to the Allstate US Standard - MM/DD/YYYY');
DatePrefCorrect = false;
}
else
{
DatePr
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide