postgresql

怎么在postgresql中计算时间差

养鱼的猫咪
3768
2021-04-27 09:25:22
栏目: 云计算

在postgresql中计算时间差的方法:1.启动postgresql服务;2.登录postgresql数据库;3.使用数据库;4.使用date_part()函数计算;

怎么在postgresql中计算时间差

具体步骤如下:

1.首先,在命令行中启动postgresql服务;

net start postgresql

2.postgresql服务启动后,在命令行中登录到postgresql数据库;

psql -h -U

3.登录到postgresql数据库后,在postgresql选择一个数据库并使用;

\c text

4.最后,进入到数据库后,在数据库中使用date_part()函数即可计算两个时间的时间差;

#计算2021年4月20日10时12分15秒至2021年4月26日10时12分15秒的时间差

select date_part('day','2021-04-20 15:49:15'::timestamp-'2021-04-26 10:12:15'::timestamp);

1
看了该问题的人还看了