我已经运行了这个简单的查询,但没有返回结果
enterselect * from record where recorddate = TO_DATE(2018, 'YYYY');
我已经测试
Select to_date(recorddate,'YYYY') from record
返回ora01830:日期格式的图片在转换整个输入字符串之前结束
这是我的表结构:
create table record(
recordid varchar2(10),
singerid varchar2(10),
producedcountryid varchar2(10),
songid varchar2(10),
recorddate date,
constraint recordid_pk primary key (recordid),
constraint singerid2_fk foreign key (singerid) references singer(singerid),
constraint songid2_fk foreign key (songid) references song(songid)
);
答案 0 :(得分:1)
DATE
包括小时,分钟和秒。
因此,除非给定月份中的所有RECORDDATE
都恰好在00:00:00之前,谓词where recorddate = TO_DATE(2018, 'YYYY')
都找不到匹配的内容。
在第二个查询中,to_date(recorddate,'YYYY')
不是使用to_date
的有效语法。有关更多信息,请参见to_date。
如果您想在2018年找到RECORD
与RECORDDATE
的所有对象,可以采用多种方法。以下是几个示例。
CREATE TABLE RECORD (LOREM_IPSUM NUMBER, RECORDDATE DATE);
INSERT INTO RECORD VALUES (1,DATE '2017-05-05');
INSERT INTO RECORD VALUES (2,DATE '2018-05-05');
COMMIT;
SELECT * FROM RECORD;
LOREM_IPSUM RECORDDATE
1 05-MAY-17
2 05-MAY-18
然后:
SELECT * FROM RECORD WHERE EXTRACT(YEAR FROM RECORDDATE) = 2018;
结果:
LOREM_IPSUM RECORDDATE
2 05-MAY-18
-或:
SELECT * FROM RECORD WHERE TO_CHAR(RECORDDATE,'YYYY') = '2018';
结果:
LOREM_IPSUM RECORDDATE
2 05-MAY-18
如果要获取特定年份和月份的记录,可以:
SELECT * FROM RECORD WHERE TRUNC(RECORDDATE,'MM') = DATE '2017-05-01';
结果:
LOREM_IPSUM RECORDDATE
1 05-MAY-17
答案 1 :(得分:0)
通过查询日期列public class GamePlayerManager : NetworkBehaviour
{
[System.NonSerialized]
public bool isPlayingOnTorn = true;
void Awake()
{
GameController.instance.EventOnNewPlayerAddedDelegate += OnRegisterPlayer;
}
private void Start()
{
if (!isLocalPlayer)
{
return;
}
}
public override void OnStartServer()
{
GameObject gc = (GameObject)Instantiate(NetworkManager.singleton.spawnPrefabs[2], transform.position, transform.rotation);
NetworkServer.Spawn(gc);
}
void OnRegisterPlayer(){
if (isLocalPlayer)
{
//GameController.instance.RegisterPlayer(this);
//RpcRegisterPlayer();
CmdRegisterPlayer();
}
}
[Command]
void CmdRegisterPlayer(){
Debug.Log("-------------Command Register player -------------");
GameController.instance.RegisterPlayer(this);
}
[ClientRpc]
void RpcRegisterPlayer()
{
Debug.Log("------------- RPC REgister Player -------------");
GameController.instance.RegisterPlayer(this);
}
}
的年份部分,将获得所需的结果集。
recorddate