Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle 从时间戳中提取年和月(6)_Oracle_Timestamp_Extract_Iso8601 - Fatal编程技术网

Oracle 从时间戳中提取年和月(6)

Oracle 从时间戳中提取年和月(6),oracle,timestamp,extract,iso8601,Oracle,Timestamp,Extract,Iso8601,我有一个数据库,我在其中插入了以下格式的时间戳(6): 2014年8月18日02.49.27.000000000下午 我想把它浓缩到这个:2014-08 它名为ISO 8601,您需要使用该函数从时间戳中提取年-月 select to_char(timestamp, 'yyyy-mm') from your_table 我是这样做的- select extract(year from timestmp) || '-' || extract(month from timestmp) from t

我有一个数据库,我在其中插入了以下格式的时间戳(6):
2014年8月18日02.49.27.000000000下午

我想把它浓缩到这个:2014-08

它名为ISO 8601,您需要使用该函数从时间戳中提取年-月

select to_char(timestamp, 'yyyy-mm') from your_table

我是这样做的-

select extract(year from timestmp) || '-' || extract(month from timestmp) from texmp1;
希望这有帮助

以下是表格结构:

    create table texmp1 
(
timestmp timestamp
);

这将使2014-8年,而不是2014-08年。对不起,也许我把你和“摘录”这个词混淆了…@KimBergHansen是对的,它不是ISO格式