当前位置: 首页 > news >正文

wordpress 上传excel正规的关键词优化软件

wordpress 上传excel,正规的关键词优化软件,网站一年多少钱,2015年全球网站优秀设计师postgresql-常用日期函数 简介计算时间间隔获取时间中的信息截断日期/时间创建日期/时间获取系统时间时区转换 简介 PostgreSQL 提供了以下日期和时间运算的算术运算符。 获取当前系统时间 select current_date,current_time,current_timestamp ;-- 当前系统时间一周后的日…

postgresql-常用日期函数

  • 简介
  • 计算时间间隔
  • 获取时间中的信息
  • 截断日期/时间
  • 创建日期/时间
  • 获取系统时间
  • 时区转换

简介

PostgreSQL 提供了以下日期和时间运算的算术运算符。
在这里插入图片描述
在这里插入图片描述
获取当前系统时间

select current_date,current_time,current_timestamp ;

在这里插入图片描述

-- 当前系统时间一周后的日期
select current_date + interval '7 day',current_time,current_timestamp ;

在这里插入图片描述

计算时间间隔

age(timestamp, timestamp)函数用于计算两个时间点之间的间隔,age(timestamp)函数用于
计算当前日期的凌晨 12 点到该时间点之间的间隔

select age(now(),date '1988-11-29') as ageResult;

在这里插入图片描述

获取时间中的信息

date_part(text, timestamp)和 extract(field FROM timestamp)函数用于获取日期时间中的某
一部分,例如年份、月份、小时等;date_part(text, interval)和 extract(field FROM interval)函数
用于获取时间间隔中的某一部分

-- 获取当前日期所属年份
select extract ('year' from now()) as t;

在这里插入图片描述

-- 判断当前日期是星期几
select extract ('dow' from now()) as t;

在这里插入图片描述

select date_part('year', timestamp '2020-03-03 20:38:40'), extract(year FROM
timestamp '2020-03-03 20:38:40'),date_part('month', interval '1 years 5 months'), extract(month FROM
interval '1 years 5 months');

在这里插入图片描述

selectdate_part('year',now()) as "当前年度",date_part('month',now()) as "当前月份",date_part('day',now()) as "当前日子",date_part('dow',now()) as "星期几";

在这里插入图片描述
extract 函数实际上也是调用了 date_part 函数,只是参数方式不同。这两个函数支持获取的信息包括

  • century,世纪;
  • day,对于 timestamp,返回月份中的第几天;对于 interval,返回天数;
  • decade,年份除以 10;
  • dow,星期天(0)到星期六(6);
  • doy,一年中的第几天,(1 - 365/366);
  • epoch,对于 timestamp WITH time zone,返回 1970-01-01 00:00:00 UTC 到该时间的秒数;
    对于 date 和 timestamp,返回本地时间的 1970-01-01 00:00:00 到该时间的秒数;对于
    interval,返回以秒数表示的该时间间隔;
  • hour,小时(1 - 23);
  • isodow,ISO 8601 标准中的星期一(1)到星期天(7)
  • isoyear,ISO 8601 标准定义的日期所在的年份。每年从包含 1 月 4 日的星期一开始,2017
    年 01 月 01 日属于 2016 年;
  • microseconds,微秒,包含秒和小数秒在内的数字乘以 1000000;
  • millennium,千年;
  • milliseconds,毫秒,包含秒和小数秒在内的数字乘以 1000;
  • minute,分钟,(0 - 59);
  • month,月份;
  • quarter,季度,(1 - 4);
  • second,秒数,包含小数秒;
  • timezone,UTC 时区,单位为秒;
  • timezone_hour,UTC 时区中的小时部分;
  • timezone_minute,UTC 时区中的分钟部分;
  • week,ISO 8601 标准中的星期几,每年从第一个星期四所在的一周开始;
  • year,年份。
-- 计算当前日期从1970年到现在的秒数
select extract('epoch' from current_date);

在这里插入图片描述

截断日期/时间

date_trunc(field, source [, time_zone ])函数用于将 timestamp、timestamp WITH time zone、
date、time 或者 interval 数据截断到指定的精度
date_trunc 函数支持以下截断精度:

  • microseconds
  • milliseconds
  • second
  • minute
  • hour
  • day
  • week
  • month
  • quarter
  • year
  • decade
  • century
  • millennium
select date_trunc('year', timestamp '2020-03-03 20:38:40'),date_trunc('day', timestamptz '2020-03-03 20:38:40+00',
'asia/shanghai'),date_trunc('hour', interval '2 days 3 hours 40 minutes');

在这里插入图片描述

创建日期/时间

make_date(year int, month int, day int)函数用于创建一个日期:
make_interval(years int DEFAULT 0, months int DEFAULT 0, weeks int DEFAULT 0, days int DEFAULT 0, hours int DEFAULT 0, mins int DEFAULT 0, secs double precision DEFAULT 0.0)函数通过指定年、月、日等信息创建一个时间间隔。
make_time(hour int, min int, sec double precision)函数通过指定小时、分钟和秒数创建一个
时间。
make_timestamp(year int, month int, day int, hour int, min int, sec double precision) 函数通过指定年、月、日、时、分、秒创建一个时间戳
make_timestamptz(year int, month int, day int, hour int, min int, sec double precision, [ timezone text ])函数通过指定年、月、日、时、分、秒创建一个带时区的时间戳。如果没有指
定时区,使用当前时区
to_timestamp(double precision)函数将 Unix 时间戳(自从 1970-01-01 00:00:00+00 以来的秒
数)转换为 PostgreSQL 时间戳数据。

select make_date(2020, 03, 15) as t1,
make_interval(days => 1, hours => 5) as t2,
make_time(1, 2, 30.5) as t3,
make_timestamp(2020, 3, 15, 8, 20, 23.5) as t4,
make_timestamptz(2020, 3, 15, 8, 20, 23.5) as t5,
to_timestamp(1583152349) as t6
;

在这里插入图片描述

获取系统时间

PostgreSQL 提供了大量用于获取系统当前日期和时间的函数,例如 current_date、current_time、
current_timestamp、clock_timestamp()、localtimestamp、now()、statement_timestamp()等;同时还
支持延迟语句执行的 pg_sleep()等函数
参考文章

-- 当前日期
select current_date as t1,
current_time as t2,
localtime as t3, 
current_timestamp as t4,
localtimestamp as t5,
now() as t6
;

在这里插入图片描述

时区转换

AT TIME ZONE 运算符用于将 timestamp without time zone、timestamp WITH time zone 以及
time WITH time zone 转换为指定时区中的时间
timezone(zone, timestamp)函数等价于 SQL 标准中的 timestamp AT TIME ZONE zone。
官网介绍

select timestamp '2020-03-03 20:38:40' at time zone 'asia/shanghai',timestamp with time zone '2020-03-03 20:38:40-05:00' at time zone
'asia/shanghai',time with time zone '20:38:40-05:00' at time zone 'asia/shanghai';

在这里插入图片描述

http://www.hkea.cn/news/115577/

相关文章:

  • 网络营销推广的作用谷歌seo什么意思
  • 免费网站建设解决方案郑州网络营销公司哪个好
  • 转转怎么做钓鱼网站税收大数据
  • 株洲专业网站排名优化深圳产品网络推广
  • 深圳美食教学网站制作如何免费搭建自己的网站
  • 兰州移动端网站建设广东整治互联网霸王条款
  • 彩票网站该怎么建设天津seo实战培训
  • 原平的旅游网站怎么做的新冠疫情最新情况最新消息
  • 网站开发软件著作权归谁seo外包
  • 小说网站的网编具体做哪些工作南宁网站快速排名提升
  • 承德网站设计seo互联网营销培训
  • 工信部网站备案查询 手机seo专员的工作内容
  • 淘宝活动策划网站视频营销成功的案例
  • 精准营销数据杭州排名优化软件
  • 中卫网站建站设计seo学习论坛
  • wordpress初始登录seo排名赚app靠谱吗
  • 软件外包保密协议seo相关岗位
  • 后台网站开发文档下载班级优化大师app
  • 辛集城乡建设管理局网站网络营销网络推广
  • 阿里云部署一个自己做的网站吗电商网站搭建
  • 免费汽车租赁网站模板网站域名解析ip查询
  • 企业解决方案官网国内seo排名分析主要针对百度
  • 变态版手游石景山区百科seo
  • 阿里云控制台登录入口seo矩阵培训
  • wordpress苗木模板网站搜索排优化怎么做
  • 网站图片引导页怎么做重庆seo招聘
  • 如何做属于自己的领券网站郑州百度网站优化排名
  • 建设银行益阳市分行桃江支行网站公司页面设计
  • vps 网站上传网站seo优化是什么意思
  • wordpress cos腾讯云seo网站优化收藏