So I'm going out tonight and tomorrow morning solo, and something I always do that I feel is a mistake is asking for a number at the wrong time. I have two examples of this.

I was talking to these two teachers at the bar. I thought one of them and I really hit it off, was talking to them both for about half an hour before they decided to leave. I told her I thought she was pretty cute and I'd like to get her number. She said she had a bf.

A few days ago I was chatting up this girl I saw in Chipotle, my first time talking to a girl like that during the day. And right before she walked out the door i asked for her number and got a similar response.

I feel like I shouldn't wait until a girl is getting ready to leave to ask, but I just don't know a better time in the conversation because I feel like saying, "hey I think you're really interesting and attractive, I'd like to see you again sometime. Can I get your number?" Should be at the end I've the conversation but idk.