This happened 17 years ago at my old job when I was 20 years old. I was hired to work the weekend shift for an IT department at a financial company but I had to come in 2 days during the first week for training, it wasn't specific to my job it was more of a “how the company works, how to enter timesheets, how to submit PTO requests, etc…” kinda training. I had already been working at the company for 6 months as an intern so I already knew all of this but it was required for me to attend as a full-time employee now.
Since I was hired to work the weekend shift these 2 training days fell on my day off and each training session was only about 4 hours each. I went into work wearing jeans and a t-shirt because why not? I was literally going to the movies afterwards so I didn't want to get dressed up in a suit for a 4-hour training session.
The moment I stepped into the building and badged through the turnstile I was stopped by security and asked what I was doing and where I got the badge. I told them I was a new hire and showed them my badge which had my photo on it from when I was still an intern so I had a different haircut. They looked me up in the system to verify and then told me about the dress code policy and that I can't wear whatever I want to work. I explained it was my day off and I was only there to go sit in a classroom for 4 hours and leave. They let me through and as I got to the classroom a manager stepped in the doorway and asked to see my badge and what I was doing there. I explained the same thing and they were not happy with my response and said they were going to talk to my manager to make sure I was aware of the dress code policy.
Everybody in the classroom commented about my choice of clothing and even the trainer asked me why I thought it was appropriate. I had to explain myself again in front of everybody and they seemed very bothered by it until I told them I worked in IT and then nobody seemed to care because I didn't deal with clients directly (nobody else in the classroom worked in IT so they all had really nice suits and ties and stuff).
After the training session was over I stopped by my new manager's desk and let him know what had happened and he said “it's your day off, who cares what you wear?” so the next day for the second training session I wore shorts just to see if anybody would comment and nobody did.
That was the first and last time I felt like I had any kind of control at my old job.