Hi
I have 2 dates in 2 cell A1 and A2 in the following format mm/dd/yyyy, hh:mmpm. can i know how would i be able to calculate the number of days difference bet these 2 dates.
Hi
I have 2 dates in 2 cell A1 and A2 in the following format mm/dd/yyyy, hh:mmpm. can i know how would i be able to calculate the number of days difference bet these 2 dates.
Try this...
=IF(DATEDIF(A1,B1,"y")=0,"",DATEDIF(A1,B1,"y")&" years ")&IF(DATEDIF(A1,B1,"ym")=0,"",DATEDIF(A1,B1,"ym")&" months ")&DATEDIF(A1,B1,"md")&" days"
If you only want the number of days, then just subtract the later date from the earlier 1, and format as general
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
Hi Ford, This formula showed an error value till I removed the time. the date i have is in the follwing format
Please Login or Register to view this content.
Attach a sample workbook (not image).
Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate.
Make sure your desired results are shown, mock them up manually if necessary.
Remember to desensitize the data.
Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
FYI: you are more likely to get a quicker response if you post a file so respondents don't have to "guess" how the data is organised and/or formatted.
Hi I have inserted a test file. I would want to count the number of days in the following format
As your "dates" are not in Excel date format ...
Try
=DATEVALUE(LEFT(A2,10))-DATEVALUE(LEFT(B2,10))+1
Last edited by JohnTopley; 07-15-2017 at 11:20 AM.
Hi @Shamz41,
If you always have comma before times in your cell, you can try this too:
=(REPLACE(A2,FIND(",",A2),99,"")+0)-REPLACE(B2,FIND(",",B2),99,"")+1
Regards,
Khalid
Thanks both formulas worked perfectly
Happy to help and thanks for the feedback
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks