+1 vote
173 views

here is my code

 @api.multi
def modification_approval(self):
    attend_signin_ids = self.env['hr.attendance'].search([('employee_id','=',self.employee_id.id)])
    check_in_date = datetime.datetime.strptime(self.time_check_in_1, "%y-%m-%d %H:%M:%S").date()
    check_out_date = datetime.datetime.strptime(self.time_check_out_1, "%y-%m-%d %H:%M:%S").date()
    for obj in attend_signin_ids:
       attendance_check_in_date = datetime.datetime.strptime(obj.check_in, "%y-%m-%d %H:%M:%S").date()
      attendance_check_out_date = datetime.datetime.strptime(obj.check_out, "%y-%m-%d %H:%M:%S").date()
in App by (10.5k points) | 173 views

1 Answer

0 votes

Hi Khayreddine,

Note the difference between:

%y - Year without century [00,99]."
%Y - Year with century."

So, I think  you need to use capital "Y" instead of "y" to format your date, also, insure that the date to convert with strptime function is in String Format:

datetime.datetime.strptime(date_in_string_format, "%Y-%m-%d %H:%M:%S")

Hope this was helpful

by (3.7k points)
202 questions
178 answers
34 comments
111,038 users