Forum Discussion

hotsurf's avatar
hotsurf
Copper Contributor
Mar 30, 2022
Solved

Date format error issue

PLEASE HELP. I'd like to use "datedif" function, but for no apparent reason, I can't seem to get a result. For example, I want to see the difference between 3/30/2022 and 3/21/2022 in terms of ...
  • Starrysky1988's avatar
    Mar 30, 2022

    hotsurf 

    Whether month or day comes first in a date is very important when you are working with the dates. When you type the date in Excel, the sequence of day and moth must always be the same as your operation system date format. Year can be first or last only by typing. If you want to see year in the middle, you need to apply custom format like "dd yyy mm" or "mm yyy dd".

    3/21/2022 3/30/2022 is month and day sequence, ignoring year.
    2022-03-21 2022-03-30 is the same as above. 

    It should work the same for both if the dates are correct date formats.
    WHY TYPE 1 DOESN'T WORK? And you got value error #value for the first one.

    That means the date is wrong and it is not the date format and has no value.
    As Mr. Peter has explained your date may not be actual date format and it may be text format that represents or looks like the date or it may be text only with wrongly typed date and month sequence.

    If the date is text format with correct sequence, you may use Datevalue or Value function to convert text to actual date format like below.

    Datevalue("3/30/2022") or Value("3/30/2022")

    Datevalue("3/21/2022") or Value("3/21/2022")

    If the date are wrongly typed in day and month sequence, you may need to use Left, Right, Mid Functions to swap day and month correctly as per the system date. 

    The syntax of Datedif function is as below.
    =Datedif(start_date, end_date, interval_unit)

    *StartDate must be minimmum date.

    *EndDate must be maximum date.

     

Resources