The present paper is dedicated to a variational method for the construction of optimal quadrature formulas in the sense of Sard in the Hilbert space W˜2(m,m−1) of complex-valued and periodic functions. In this, the coefficients of the optimal quadrature formula are found separately in the case ωh is integer and non-integer cases. In addition, using the constructed optimal quadrature formula, the numerical results of exponentially weighted integrals of certain functions in the case m=2 is presented. The numerical results show that the order of convergence of the optimal quadrature formula is O1N+|ω|2 in the space W˜2(2,1).