Absolutely. I fly fairly regularly and just had a 6 hour flight last week. As others have mentioned I try and not eat much or eat something small that is binding a couple of hours before I go. I normally also take an Imodium before I get on.
I can usually end up going to whole flight without having to use a washroom. Honestly, I think it is more mental than anything. The first couple of flights all I could think about was when I would need to go. As someone else mentioned do something to take your mind off it.