Hi Team i have models as below. And i am trying to substract out time and in time .
class Attendance(models.Model):
employee = models.ForeignKey(Employee, on_delete=models.CASCADE,
default=1, related_name='Attendance')
attendance_date = models.DateField(null=True)
in_time = models.TimeField(null=True)
out_time = models.TimeField(null=True, blank=True)
totaltime = models.TimeField(null=True, blank=True)
def __str__(self):
return str(self.employee) + '-' + str(self.attendance_date)
@property
def totaltime(self):
FMT = '%H:%M:%S'
currentDate = date.today().strftime('%Y-%m-%d')
sub = datetime.strptime('out_time', FMT) -
datetime.strptime('in_time', FMT)
return sub
Still getting and error: ValueError: time data 'out_time' does not match format '%H:%M:%S'
Please advise what should i do ,I am expecting how i will substract two timefeild