This might be G.I. Samurai (1979), also titled I Want To (original title, per IMDb is Sengoku jieitai). The plot description on Wikipedia says:
During a defensing exercise, a wildly mixed group of Japanese SDF members with a tank, an APC, a patrol boat and a helicopter suddenly find themselves stranded 400 years in the past and under attack by samurai forces. Their acting commanding officer, Second Lieutenant Yoshiaki Iba, befriends and joins forces with Nagao Kagetora, the war leader of lord Koizumi. Seeing the stranded members' defensing machinery in action, Kagetora persuades Iba to aid him in his struggle for supremacy in feudal Japan.
In the meantime, however, Iba finds himself facing the desperation of his men who want to return to their own time. Some make contact with the locals - one of the members, Private First Class Mimura, even finds himself a consort who keeps following him - whilst others freak out, running away in a desperate attempt to return home, or rebelling against rules and restrictions and try to live a pirate's life. Finally, his force shrunk from 21 men to 11, Iba manages to calm his troops by telling them that by fighting history and thus creating a time paradox they might be able to return home. Iba joins Kagetora and fights by his side.