@Cron('23 16 * * *')
async transferData() {
try {
// Retrieve data from the AttendanceBulk table
const attendanceBulkData = await this.AttendanceBulkModel.findAll();
for (const data of attendanceBulkData) {
const attendance = new Attendance();
// Find the corresponding AttendanceAndBulk entry based on data.UserId
const attendanceAndBulk = await AttendanceAndBulk.findOne({ where: { UserId: data.UserId } });
if (attendanceAndBulk) {
attendance.employeeId = attendanceAndBulk.employeeId;
attendance.shiftType = data.Intime ? ShiftType.In : ShiftType.Out;
attendance.time = new Date(`${data.Intime}`);;
attendance.date = data.Date;
attendance.outTime= data.Date;
console.log(data.Intime)
await attendance.save();
}
}
this.logger.log('Data transfer completed successfully.');
} catch (error) {
this.logger.error('Data transfer failed:', error);
}
}
In above code I data.Intime is comming like 00:39:41 this. but attendance.date variable is Date type. how can I convert time varibale(00:39:41) to Date type in nest js?