Let G be a connected graph of order n ≥ 3 and let c : E(G) → {1, 2, . . . , k} be a coloring of the edges of G (where adjacent edges may be colored the same). For each vertex v of G, the color code of v with respect to c is the k-tuple c(v) = (a1, a2, . . . , ak), where ai is the number of edges incident with v that are colored i (1 ≤ i ≤ k). The coloring c is detectable if distinct vertices have distinct color codes. The detection number det(G) of G is the minimum positive integer k for which G has a detectable k-coloring. We establish a formula for the detection number of a path in terms of its order. For each integer n ≥ 3, let Du(n) be the maximum detection number among all unicyclic graphs of order n and du(n) the minimum detection number among all unicyclic graphs of order n. The numbers Du(n) and du(n) are determined for all integers n > 3. Furthermore, it is shown that for integers k ≥ 2 and n ≥ 3, there exists a unicyclic graph G of order n having det(G) = k if and only if du(n) ≤ k ≤ Du(n).