We propose the difference discrete variational principle in discrete mechanics and symplectic algorithmwith variable step-length of time in finite duration based upon a noncommutative differential calculus established inthis paper.This approach keeps both symplecticity and energy conservation discretely.We show that there exists thediscrete version of the Euler-Lagrange cohomology in these discrete systems.We also discuss the solution existencein finite time-length and its site density in continuous limit,and apply our approach to the pendulum with periodicperturbation.The numerical results are satisfactory.