任何人都可以帮助我使用日期命令

时间:2015-10-22 16:17:06

标签: mysql date

所以我已经通过网络搜索sql中的基本日期帮助,似乎没有人能够帮助我的代码像这样

create table Hotel
(
    id int not null primary key auto_increment,
    Name varchar(255)
);

create table Gestur
(
    id int not null primary key auto_increment,
    nafn varchar(255),
    heimili varchar(255),
    simi char(7),
    netfang varchar(255)
);

create table Bokun
(
    id int not null primary key auto_increment,
    ID_hotel_fk int references Hotel(id),
    ID_gestur_fk int references Gestur(id),
    dags_inn date null,
    dags_ut date null,
    tegund_herbergis char(1)
);

我似乎无法正确使用这部分

insert into Bokun
(ID_gestur_fk,ID_hotel_fk,dags_inn,dags_ut,tegund_herbergis)
values
(1,3, 2015-10-25,2016-12-26,"1"),
(2,5, 2015-04-01, 2016-8-24,"3"),
(3,4, 2014-02-24, 2016-12-08,"1"),
(4,2, 2015-04-26, 2016-12-24,"2"),
(5,4, 2015-07-14, 2016-04-23,"1"),
(6,2, 2015-12-12, 2016-09-12,"3"),
(7,3, 2015-12-26, 2016-05-03,"2"),
(8,2, 2013-09-12, 2014-06-10,"1"),
(9,1, 2015-05-26, 2016-12-28,"1"),
(10,5, 2015-03-30, 2016-06-07,"4");

我只收到错误

  

1292 - 日期值不正确:第1行第'dags_inn'栏的'1980'

2 个答案:

答案 0 :(得分:1)

您需要引用self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 50)]; for (UIView *subview in self.searchBar.subviews) { if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) { [subview removeFromSuperview]; break; } for (UIView *subsubview in subview.subviews) { if ([subsubview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) { [subsubview removeFromSuperview]; break; } } } self.searchBar.barTintColor = [UIColor redColor]; self.searchBar.backgroundColor = [UIColor redColor]; 和qoute '作为"1"的日期:

'1'

insert into Bokun(ID_gestur_fk,ID_hotel_fk,dags_inn,dags_ut,tegund_herbergis) values(1,3, '2015-10-25','2016-12-26','1'); 被视为2015-10-25(aritmetic operation substraction)

SqlFiddleDemo

答案 1 :(得分:-1)

insert into Bokun
(ID_gestur_fk,ID_hotel_fk,dags_inn,dags_ut,tegund_herbergis)
values
(1,3, '2015-10-25','2016-12-26',"1"),
(2,5, '2015-04-01', '2016-8-24',"3"),
(3,4, '2014-02-24', '2016-12-08',"1"),
(4,2, '2015-04-26', '2016-12-24',"2"),
(5,4, '2015-07-14', '2016-04-23',"1"),
(6,2, '2015-12-12', '2016-09-12',"3"),
(7,3, '2015-12-26', '2016-05-03',"2"),
(8,2, '2013-09-12', '2014-06-10',"1"),
(9,1, '2015-05-26', '2016-12-28',"1"),
(10,5, '2015-03-30', '2016-06-07',"4");

您错过了'quotes)。感谢此帮助..