# Yield year if criteria is between two dates in two columns.

Options
✭✭✭

Hello,

I am trying to yield the Year if Start date is greater than or equal to 1/1/2023 but pre-marketing date is less than or equal to 12/31/2023.

I was fine with a simple year in a single column but am stumped with yielding year between two dates in two columns.

Thanks!

Tags:

• ✭✭✭✭✭✭
Options

You can nest an IF function inside of the YEAR function to choose which date to output.

=IF([Pre-Marketing Date]@row <> "", [Pre-Marketing Date]@row, [Start Date]@row)

Now that we have the IF outputting the date we want to use, we wrap the whole thing in a YEAR function.

=YEAR(IF([Pre-Marketing Date]@row <> "", [Pre-Marketing Date]@row, [Start Date]@row))

• ✭✭✭✭✭✭
Options

What if the dates are in different years?

• ✭✭✭
Options

Very good question and I'm not thinking this through properly. With the example above, sometimes the pre-marketing field is not filled out, but start date is. Default should always be pre-market date but if pre-market date isn't filled out, then start date should be used. Is this even possible?

• ✭✭✭✭✭✭
Options

You can nest an IF function inside of the YEAR function to choose which date to output.

=IF([Pre-Marketing Date]@row <> "", [Pre-Marketing Date]@row, [Start Date]@row)

Now that we have the IF outputting the date we want to use, we wrap the whole thing in a YEAR function.

=YEAR(IF([Pre-Marketing Date]@row <> "", [Pre-Marketing Date]@row, [Start Date]@row))

• ✭✭✭
Options

Hey! Thanks for the assist here. This formula is yielding an invalid data type, but is pulling the data correctly. Thoughts?

• ✭✭✭
Options

Hey nevermind! I wrapped it in IFERROR and it worked. Thank you so much!!

• ✭✭✭✭✭✭
Options

Happy to help. 👍️

## Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!