An undated portrait usually dates itself, if you know which details changed and when.

Studio card mounts, borders and the photographer's imprint followed commercial fashions that are well catalogued, and they often narrow a date to a few years before you have looked at the uniform at all.
Collar devices, shoulder titles, rank marking and badge placement were altered by regulation, and those regulations are published. A single visible detail can place a photograph on one side or the other of a specific year.
Studio photographs sometimes show garments that were not the sitter's: props kept by the photographer, a brother's jacket, a uniform issued for training and never worn in service. Treat the clothing as evidence about the photograph, not automatically about the person.
The reliable method is comparison with dated examples rather than identification from memory. Published reference collections exist for exactly this, and a cautious range of years is worth more than a confident wrong answer.
Backgrounds, furniture and the other people present often date a photograph as reliably as the uniform does, and they are harder to borrow. A studio chair, a painted backdrop or a civilian hat in the corner can settle a question that the tunic leaves open.