Home > Ask the Domino Experts > Application Development Questions & Answers > Calculating time difference in Formula language or LotusScript
Ask The Domino Expert: Questions & Answers
EMAIL THIS

Calculating time difference in Formula language or LotusScript

Brian Mahoney EXPERT RESPONSE FROM: Brian Mahoney

Pose a Question
Other Domino Categories
Meet all Domino Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 28 July 2003
I need to calculate the time difference between two dates in Formula language or LotusScript and then return the result in the format of "x months and y days." Do you know of any scripts or @Formulas that can do this?


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Application Development
Calculating results for a column in a Lotus Notes view
Do I use Formula or LotusScript to include a doclink to a Notes view?
'Customize this view' options are disabled in Lotus Notes databases
Give external users access to workflow-based Notes Domino applications
Setting the field value of a table
Troubleshooting non-delivery of agent notification e-mails
Exporting data from Microsoft Excel to Lotus Notes
How to send a form to a non-Lotus Notes email client
Manipulating the replication and form of profile documents
How to create an icon on an HTML page that opens the Lotus Notes database from a Lotus Notes client

Lotus Notes Domino Formula Language
View hidden fields on Lotus Notes/Domino forms
Case-insensitive @Unique version combines fields on Lotus Notes forms
Do I use Formula or LotusScript to include a doclink to a Notes view?
Top 10 Lotus Notes/Domino coding and development tips of 2008
Provide rich-text formatting via the Profile document and Formula
Top 10 Formula language tips
Using Formula language code to sort Lotus Notes messages by subject
How to create dynamic JavaScript in Notes Domino without formulas
Stop response documents from showing in a Lotus Notes form
Formula language button manages Deny Access list searches

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


I used a formula to calculate the difference. This does not include code for leap year and assumes that date1, the first date, is always earlier than date2. Here's the formula for a text field.

year1   := @IF(date1=""; 0; @Year(date1));
year2   := @IF(date2=""; 0; @Year(date2));
month1:= @IF(date1=""; 0; @Month(date1));
month2:= @IF(date2=""; 0; @Month(date2));
day1    := @IF(date1=""; 0; @day(date1));
day2    := @IF(date2=""; 0; @day(date2));
daysinmonth := @IF(date1=""; 
0;
@Select(month1;31;28;31;30;31;
30;31;31;30;31;30;31));
tempmonth:=@IF (year1=year2;
 month2 - month1;
 ((year2-year1)*12) + month2 - month1);
months:=@IF(day2<day1;
tempmonth - 1; 
tempmonth);
days:=@IF(day1<=day2;
 day2 - day1;
  daysinmonth + day2 - day1);
"sample: " + @text(months) + 
" months and " + @Text(days) + " days." 




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Lotus Notes Domino on Blackberry and mobile devices
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts