DATEDIF

%3CLINGO-SUB%20id%3D%22lingo-sub-1509468%22%20slang%3D%22en-US%22%3EDATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509468%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20DATEDIF%20function%20to%20calculate%20an%20age%20of%20person%20in%20years%20at%20a%20specific%20date.%20Formula%20example%3A%20%3DDATEDIF(F2%2C%2209%2F01%2F2020%22%2C%22y%22).%20%26nbsp%3BIn%20my%20s%2Fs%2C%20cell%20F2%20is%20their%20birthday%20and%20reads%3A%2024-Feb-03.%20The%20formula%20gives%20%23VALUE!%3C%2FP%3E%3CP%3Ethanks%20for%20any%20help!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1509468%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509530%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509530%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F722562%22%20target%3D%22_blank%22%3E%40ajcameron1929%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhich%20format%20is%20in%20F2%20it%20doesn't%20matter%2C%20it's%20important%20you%20have%20date%20not%20text.%20You%20may%20check%20by%20%3DISNUMBER(F2)%20in%20any%20empty%20cell.%20If%20TRUE%20when%20date.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20formula%20better%20to%20use%20DATE()%20instead%20of%20text%20to%20avoid%20regional%20settings%20issues.%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DDATEDIF(F2%2CDATE(2020%2C9%2C1)%2C%22y%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EEven%20better%20second%20date%20also%20have%20in%20cell.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509534%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509534%22%20slang%3D%22en-US%22%3EI%20haven't%20been%20able%20to%20replicate%20the%20problem%20in%20my%20Excel.%20What%20does%20occur%20to%20me%20is%20that%20your%20system%20may%20be%20comparing%20one%20true%20date%20value%20with%20a%20text%20that%20looks%20date-like.%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20I'd%20recommend%2C%20in%20any%20event%2C%20instead%20of%20hard-coding%20the%20DATEDIF%20function%20with%20the%20date%20for%20which%20you%20want%20the%20age%2C%20put%20that%20in%20cell%20E2.%20Then%2C%20making%20sure%20that%20both%20E2%20and%20F2%20contain%20dates%20properly%20formatted%2C%20use%20the%20formula%20%3DDATEDIF(F2%2CE2%2C%22y%22)%3CBR%20%2F%3E%3CBR%20%2F%3EIt's%20generally%20better%20not%20to%20hard-code%20variables%20into%20formulas%3B%20makes%20them%20far%20less%20flexible.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1579387%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579387%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BI'd%20be%20grateful%20if%20you%20could%20help%20me%3A%20Im%20trying%20to%20get%20a%20difference%20in%20days%20between%202%20dates%2C%20e.g.%20date%2001%2F01%2F2019%20and%2001%2F01%2F2020%20and%20am%20using%20the%20formula%20%3Ddatedif(d3%2Cq3%2C%22d%22).%20For%20some%20reason%2C%20instead%20of%20giving%20me%20days%20the%20answer%20is%20a%20date%20which%20doesn't%20make%20sense.%26nbsp%3B%26nbsp%3BI'm%20not%20sure%20what%20I'm%20doing%20incorrectly.%20The%20columns%20d3%20and%20q3%20are%20formatted%20to%20standard%20'date'.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1579419%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579419%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F755193%22%20target%3D%22_blank%22%3E%40MaCa87%3C%2FA%3E%20Format%20the%20cell%20with%20the%20DATEDIF%20formula%20as%20General.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1579482%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579482%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F722562%22%20target%3D%22_blank%22%3E%40ajcameron1929%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20formula%20cannot%20give%20a%20negative%20number.%20You%20have%20your%20start%20and%20end%20reversed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1579508%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579508%22%20slang%3D%22en-US%22%3EMy%20answer%20was%20goofy%20and%20wrong.%20I%20entered%20it%20and%20it%20did%20not%20work%2C%20now%20it%20does.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1579605%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579605%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F755193%22%20target%3D%22_blank%22%3E%40MaCa87%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20general%20formula%20shall%20work.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20325px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211553iFD4B1B46FC009FDF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFormat%20doesn't%20matter%2C%20actual%20values%20are%20important.%20Perhaps%20you%20may%20submit%20small%20file%20similar%20to%20above%20(not%20screenshot%2C%20excel%20file)%20to%20check%20what's%20wrong.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1580556%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1580556%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3Bthanks%20this%20fixed%20it%2C%20format%20was%20set%20to%20date!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1580563%22%20slang%3D%22en-US%22%3ERe%3A%20DATEDIF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1580563%22%20slang%3D%22en-US%22%3Efixed%20it%2C%20thank%20you!%3C%2FLINGO-BODY%3E
Occasional Visitor

I am using DATEDIF function to calculate an age of person in years at a specific date. Formula example: =DATEDIF(F2,"09/01/2020","y").  In my s/s, cell F2 is their birthday and reads: 24-Feb-03. The formula gives #VALUE!

thanks for any help!

9 Replies

@ajcameron1929 

Which format is in F2 it doesn't matter, it's important you have date not text. You may check by =ISNUMBER(F2) in any empty cell. If TRUE when date.

 

In formula better to use DATE() instead of text to avoid regional settings issues.

=DATEDIF(F2,DATE(2020,9,1),"y")

Even better second date also have in cell.

I haven't been able to replicate the problem in my Excel. What does occur to me is that your system may be comparing one true date value with a text that looks date-like.

What I'd recommend, in any event, instead of hard-coding the DATEDIF function with the date for which you want the age, put that in cell E2. Then, making sure that both E2 and F2 contain dates properly formatted, use the formula =DATEDIF(F2,E2,"y")

It's generally better not to hard-code variables into formulas; makes them far less flexible.

@Sergei Baklan I'd be grateful if you could help me: Im trying to get a difference in days between 2 dates, e.g. date 01/01/2019 and 01/01/2020 and am using the formula =datedif(d3,q3,"d"). For some reason, instead of giving me days the answer is a date which doesn't make sense.  I'm not sure what I'm doing incorrectly. The columns d3 and q3 are formatted to standard 'date'.

 

@MaCa87 Format the cell with the DATEDIF formula as General.

@ajcameron1929 

This formula cannot give a negative number. You have your start and end reversed.

My answer was goofy and wrong. I entered it and it did not work, now it does.

@MaCa87 

In general formula shall work.

image.png

Format doesn't matter, actual values are important. Perhaps you may submit small file similar to above (not screenshot, excel file) to check what's wrong.

@Hans Vogelaar thanks this fixed it, format was set to date!

fixed it, thank you!