当前位置:网站首页>Kingbasees plug-in KDB of Jincang database_ date_ function
Kingbasees plug-in KDB of Jincang database_ date_ function
2022-07-03 04:22:00 【Thousands of sails passed by the side of the sunken boat_】
1. kdb_date_function Introduce
kdb_date_function It's a compatible mysql database date Extension of correlation function .
You need to create extension kdb_date_function, When you don't need to drop extension kdb_date_function that will do .
2. date_add
date_add — Realize the addition of dates
grammar :
date_add(ts timestamp, iv interval) return timestamp. date_add(tstz timestamptz, iv interval) return timestamptz.
describe :
date_add Will come true timestamp or timestamptz And interval Perform the operation of addition .
Parameters :
iv
Used in date addition operation interval Type values .
ts
Used in date addition operation timestamp Type values .
tstz
Used in date addition operation timestamptz Type values .
Return value :
Return the specific date type value after calculation .
annotation :
give an example :
select date_add('2000-10-10'::timestamp,interval '1 year');
date_add
--------------------------
Wed Oct 10 00:00:00 2001
(1 row)
select date_add('2010-10-10 12:00:00'::timestamp,interval '1 year 1 day 2 hour');
date_add
--------------------------
Tue Oct 11 14:00:00 2011
(1 row)
3. dateadd
dateadd — Realize the addition of dates
grammar :
dateadd(i_unit text, i_value numeric, i_date time) return time.
dateadd(i_unit text, i_value numeric, i_date timestamp) return timestamp.
dateadd(i_unit text, i_value numeric, i_date timestamptz) return timestamptz.
describe :
Realization timestamp or timestamptz or time Type is added to the specified format .
Parameters :
i_unit
Specify what to add i_value The format of .
i_value
Specify the quantity to add .
i_date
Specify the date to be added .
Return value :
Return the specific date type value after calculation .
annotation :
i_unit The value of can make 'second','minute','hour','day','week','month','year' etc. .
give an example :
SELECT dateadd(year,9998,'0001-01-01 00:00:00'::timestamptz);
dateadd
------------------------------
Fri Jan 01 00:00:00 9999 PST
(1 row)
SELECT dateadd(year,201,'1900-01-01 00:00:00'::timestamptz);
dateadd
------------------------------
Sat Jan 01 00:00:00 2101 PST
(1 row)
SELECT dateadd(year,30,'1970-01-01 00:00:00'::timestamptz);
dateadd
------------------------------
Sat Jan 01 00:00:00 2000 PST
(1 row)
SELECT dateadd(year,-9998,'9999-12-31 00:00:00'::timestamptz);
dateadd
------------------------------
Mon Dec 31 00:00:00 0001 PST
(1 row)
SELECT dateadd(year,-100,'2000-12-31 00:00:00'::timestamptz);
dateadd
------------------------------
Mon Dec 31 00:00:00 1900 PST
(1 row)
SELECT dateadd(year,-34,'2004-12-31 00:00:00'::timestamptz);
dateadd
------------------------------
Thu Dec 31 00:00:00 1970 PST
(1 row)
4. datediff
Compare the difference between the two dates
grammar :
datediff(d1 date, d2 date) return integer. datediff(t text, d1 date, d2 date) return int8. datediff(t text, d1 time, d2 time) return int8. datediff(t text, d1 timetz, d2 timetz) return int8. datediff(t text, d1 timestamp, d2 timestamp) return int8. datediff(t text, d1 timestamptz, d2 timestamptz) return int8.
describe :
Compare the specified... Between two dates text( If this parameter exists ) The format gap .
Parameters :
t
The format of the specified date gap to be returned .
d1,d2
Two date values for comparison .
Return value :
return text Integer value in the format specified by type .
annotation :
t The value of can make 'second','minute','hour','day','week','month','year' etc. .
give an example :
SELECT datediff('year','0001-01-01'::date,'9999-12-31'::date);
datediff
----------
9998
(1 row)
SELECT datediff('year','1900-01-01 00:00:00'::date,'2000-12-31 00:00:00'::date);
datediff
----------
100
(1 row)
SELECT datediff(month,'0001-01-01 00:00:00'::date,'9999-12-31 00:00:00'::date);
datediff
----------
119987
(1 row)
SELECT datediff(month,'1900-01-01 00:00:00'::date,'2000-12-31 00:00:00'::date);
datediff
----------
1211
(1 row)
SELECT datediff('month','0001-01-01 00:00:00'::date,'9999-12-31 00:00:00'::date);
datediff
----------
119987
(1 row)
SELECT datediff('month','1900-01-01 00:00:00'::date,'2000-12-31 00:00:00'::date);
datediff
----------
1211
(1 row)
5. date_format
Get the specified format value of the specified date .
grammar :
date_format(d timestamp, t text) return text. date_format(d timestamptz, t text) return text.
describe :
Return date type value text Specified format .
Parameters :
t
Specifies the format of the date to return .
d
Value of target format .
Return value :
return text designated text Type value .
annotation :
t The value of can be nls_date_format All values of type .
give an example :
select date_format('2000-10-10 12:00:00','mm-yyyy-dd hh24:mi:ss');
date_format
---------------------
10-2000-10 12:00:00
(1 row)边栏推荐
- 类的基础语法
- Basic MySQL operations
- sklearn数据预处理
- x Problem B
- Redis persistence principle
- CVPR 2022 | Dalian Technology propose un cadre d'éclairage auto - étalonné pour l'amélioration de l'image de faible luminosité de la scène réelle
- MongoDB 慢查询语句优化分析策略
- 跨境电商多商户系统怎么选
- Mila、渥太华大学 | 用SE(3)不变去噪距离匹配进行分子几何预训练
- Nat. Comm. | use tensor cell2cell to deconvolute cell communication with environmental awareness
猜你喜欢

Prefix and (continuously updated)

The 10th China Cloud Computing Conference · China Station: looking forward to the trend of science and technology in the next decade

The latest activation free version of Omni toolbox

Design and implementation of JSP logistics center storage information management system

vulnhub HA: Natraj

因果AI,下一代可信AI的产业升级新范式?

Some information about the developer environment in Chengdu

JS realizes the animation effect of text and pictures in the visual area

leetcode:297. Serialization and deserialization of binary tree

一名外包仔的2022年中总结
随机推荐
[set theory] set concept and relationship (set family | set family examples | multiple sets)
Square root of X
[set theory] set concept and relationship (true subset | empty set | complete set | power set | number of set elements | power set steps)
深潜Kotlin协程(二十):构建 Flow
RSRS指标择时及大小盘轮动
Redraw and reflow
Application of I2C protocol of STM32F103 (read and write EEPROM)
Interaction free shell programming
类的基础语法
有监督预训练!文本生成又一探索!
The latest activation free version of Omni toolbox
Deep dive kotlin synergy (19): flow overview
Interface in TS
The 10th China Cloud Computing Conference · China Station: looking forward to the trend of science and technology in the next decade
vulnhub HA: Natraj
FFMpeg filter
Preliminary cognition of C language pointer
Nat. Comm. | use tensor cell2cell to deconvolute cell communication with environmental awareness
[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
MySQL create table