我想将从文本框中获取的时间插入 mysql 数据库 TIME 列。我想我需要在查询中使用“STR_TO_DATE”将字符串转换为时间,就像在mysql中将字符串转换为日期一样。我寻找答案,但没有得到我需要的答案。
编辑:来自评论的 SQL:
"insert into schedules (
courseid,
batch,
subjectid,
teacherid,
stime,
etime,
date,
location,
building,
department,
hall,
status
) values ('" +
getCourse() + "','" +
getBatch() + "', '" +
getSubject() + "','" +
getTeacher() + "', '" +
getStime()+ "','" +
getEtime()+
"',STR_TO_DATE('" + getDate() + "','%d-%m-%Y'),'" +
getLocation() + "', '" +
getBuilding() + "', '" +
getDepartment()+ "', '" +
getHall() +
"','ACTIVE')"