Library › Data AI › Marketing and content

Count campaign days, including ones still running

  • For Marketing and content
  • You practice Giving the right context
  • Time about 5 minutes

About this exercise

You want column D of the Campaigns sheet to show how many days each campaign has run, counting both the start and end dates, and campaigns with a blank end date are still live and should count through today. Ask for one formula for D2 in one code block, then exactly 2 numbered lines labeled Counts: (in plain words) and Check: (the Fall Sale row's answer). Under 45 words outside the code.

Common mistakes when you ask AI for this

  • Not saying both days count. The AI subtracts the dates, so a one-day campaign shows 0, like your first try. Try: Add: "Count both the start and end dates."
  • Forgetting live campaigns. The AI's formula shows a negative number for blank end dates. Try: Add: "Blank end date means still live; count through today."
  • No check row. Without a known answer, you can't tell if it's right. Try: Add: "Check: the Fall Sale row's answer."
  • Getting a menu of options. The AI likes to offer two or three versions of the formula, so you're left to pick and test them yourself. Try: Add: "Give one formula only, in one code block, no alternatives."
  • Getting a tutorial. By default the AI explains every part of the formula at length. Try: Add: "Each line under 15 words. Nothing else."

What a strong prompt includes

  • Counts both days
  • Handles live campaigns
  • Asks for a check row
  • Asks for one formula

Practice this now ↑

Related exercises