Title: date difference
Last modified: April 3, 2023

---

# date difference

 *  Resolved [civilvicky](https://wordpress.org/support/users/civilvicky/)
 * (@civilvicky)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/date-difference-2/)
 * Hello,
 * I am trying to calculate the date difference. I am using the formula **DATEDIFF(
   NOW(), fieldname1, ‘dd-mm-yyyy’, ‘y’)[‘years’]**
 * The result I am getting is only in years. Is it possible to show years, months,
   and days.
 * For example if I enter the date in fieldname as 01/04/2023, I should get the 
   output as ‘1 year 0 months 2 days’

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/date-difference-2/#post-16621703)
 * Hello [@civilvicky](https://wordpress.org/support/users/civilvicky/)
 * Yes, of course. The code in this case would be:
 *     ```wp-block-code
       (function(){
       var o = DATEDIFF(NOW(), fieldname1, 'dd-mm-yyyy', 'y');
       return o['years']+' year '+o['months']+' months '+o['days']+' days';
       })();
       ```
   
 * Best regards.
 *  Thread Starter [civilvicky](https://wordpress.org/support/users/civilvicky/)
 * (@civilvicky)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/date-difference-2/#post-16625556)
 * Its working but not 100%. For example, I entered a date as 05/28/1995, the output
   I am getting is ’27 year(s) 10 month(s) 8 day(s)’, but the correct one is 27 
   year(s) 10 month(s) 13 day(s).
 * P.S : Also if we can output the same date next year. For example in our case,
   calculatedfield = 01/04/2024 (when user enter 01/04/2023)
    -  This reply was modified 3 years, 2 months ago by [civilvicky](https://wordpress.org/support/users/civilvicky/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/date-difference-2/#post-16625925)
 * Hello [@civilvicky](https://wordpress.org/support/users/civilvicky/)
 * No, I’m sorry, you are confused. The difference between 05/28/1995 and today 
   is 27 year(s) 10 month(s) 8 day(s)
 * I’ve calculated it with Excel:
 * ![](https://i0.wp.com/resources.developers4web.com/cff/tmp/2023/04/04/excel.png?
   ssl=1)
 * There is a difference of one day because our plugin takes into account the first
   and the last day.
 * About your second question, you can use the DATETIMESUM operation to increase
   the date object and the GETDATETIMESTRING operation to get the date object as
   text in a specific format:
 *     ```wp-block-code
       GETDATETIMESTRING(DATETIMESUM('01/04/2023', 'mm/dd/yyyy', 1, 'y'), 'mm/dd/yyyy')
       ```
   
 * Learn more about the date/time operations module by reading the following section
   in the plugin documentation:
 * [https://cff.dwbooster.com/documentation#datetime-module](https://cff.dwbooster.com/documentation#datetime-module)
 * Best regards.
 *  Thread Starter [civilvicky](https://wordpress.org/support/users/civilvicky/)
 * (@civilvicky)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/date-difference-2/#post-16638292)
 * datetimesum() formula is displaying the result as “Sat Jun 03 2023 05:30:00 GMT
   +0530 (India Standard Time)”. I just need it to display date i.e “Jun 03 2023”
   or “Sat Jun 03 2023”
    -  This reply was modified 3 years, 2 months ago by [civilvicky](https://wordpress.org/support/users/civilvicky/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/date-difference-2/#post-16638530)
 * Hello [@civilvicky](https://wordpress.org/support/users/civilvicky/)
 * The DATETIMESUM operation returns a Date object. The alternatives would be call
   the WEEKDAYNAME, MONTHNAME, and YEAR operations using the DATETIMESUM. For example:
 *     ```wp-block-code
       (function(){
       var d = DATETIMESUM(fieldname1, 'yyyy-mm-dd', 7, 'd');
       return WEEKDAYNAME(d)+' '+MONTHNAME(d)+' '+DAY(d)+' '+YEAR(d);
       })()
       ```
   
 *  Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘date difference’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/date-difference-2/#post-16638530)
 * Status: resolved