我有以下代码:
sprintf(aCommand,"insert into Schedule
set StartTime = TIME(STR_TO_DATE(%s,"%h:%i %p")),
EndTime = TIME(STR_TO_DATE(%s,"%h:%i %p")),
DayofWeek = '%s',
Activity = '%s %s %s'",arr[2],arr[3],arr[1],arr[0],arr[4],arr[5]);
我有Schedule
带有列的表: StartTime
、EndTime
和。我有一个时间字符串,格式如下:. 我上面的查询给了我错误。如何将该格式存储到MySQL中的数据类型?DayofWeek
Activity
10:00 AM
time
10:00:00
编辑:这是新代码。
sprintf(aCommand,"insert into Schedule
set StartTime = TIME(STR_TO_DATE(%s,'%h:%i %p')),
EndTime = TIME(STR_TO_DATE(%s,'%h:%i %p')),
DayofWeek = '%s',Activity = '%s %s %s'",arr[2],arr[3],arr[1],arr[0],arr[4],arr[5]);
这给了我错误:
mp1a.c: In function ‘main’:
mp1a.c:45:4: warning: unknown conversion type character ‘:’ in format [-Wformat]
mp1a.c:45:4: warning: format ‘%i’ expects argument of type ‘int’, but argument 4 has type ‘char *’ [-Wformat]
mp1a.c:45:4: warning: unknown conversion type character ‘:’ in format [-Wformat]
mp1a.c:45:4: warning: format ‘%i’ expects argument of type ‘int’, but argument 7 has type ‘char *’ [-Wformat]
mp1a.c:45:4: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat]
mp1a.c:45:4: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat]
mp1a.c:45:4: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat]
mp1a.c:45:4: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat]