sql语句截取字符串
Postgresql 当中有四种方式获取当前时间。
一:now()
通过now()获取的时间是最完整的时间,包括时区,秒也保留到了6位小数。
select now();
得到的结果如下
'2014-12-24 09:28:31.545145+08'
二:current_timestamp效果是和now()一样的。
三:current_time
只显示当前的时间,不包括日期
select current_time;
得到的结果如下
'09:32:02.039705+08'
四:current_date
只显示当前的日期,不包括小时等信息
select current_date;
得到的结果如下
'2014-12-24'
我们还可以控制now()的返回格式,如下
select now()::timestamp(0)without time zone;(current_timestamp 是和now()一样的)
时间的计算方式,如下
select now() + interval '10 min/year/month/day/hour/sec/ (1 year 1 month 1 day 1 hour 1 min 1 sec)'
2.时间的计算
--使用interval
select now()+interval '2 day'; --2012-05-14 20:05:32.796+08 2天后
select now()-interval '2 day'; --2012-05-10 20:07:23.265+08 2天前
select now()+interval '2 hour'; --2012-05-12 22:06:38.375+08 2小时后
case when left(t5.name,2)='20' then substring(t5.name,9,2) else substring(t5.name,7,2) end GD
截取前1~10位数字 ac17072408
select substring(name,0,11) from profin_application;
name=ac1707240801
select substring(name,0,11) from profin_application;
select left(name,10) from profin_application;
select t1.name ,timeadd('hour',8,t1.date),t3.name_template ,left(t3.name_template,3) ,substring(t3.name_template,6,3) 号,t4.material ,t4.cust_spec ,
t5.name ,case when left(t5.name,2)='20' then substring(t5.name,3,6) else left(t5.name,6) end pp,case when left(t5.name,2)='20' then substring(t5.name,9,2) else substring(t5.name,7,2) end GD ,right(t5.name,3) ,t6.name ,t8.name ,t2.lqty
from mrp_production_report t1
left join mrp_production_report_line t2 on t1.id=t2.line_id
left join product_product t3 on t2.lproduct_id=t3.id
left join product_template t4 on t3.product_tmpl_id=t4.id
left join mrp_production_report_lot t5 on t5.id=t2.lot_id
left join mrp_routing_workcenter t6 on t6.id=t2.lprocedure
left join res_users t7 on t7.id=t2.lemployee
left join res_partner t8 on t8.id=t7.partner_id
where t2.lstate=2 and t6.name='分选' or t6.name='包装' and t1.company_id=4 and t1.date>='${sd} 0:00:00' and t1.date<='${ed} 23:59:59'
sql语句截取字符串的更多相关文章
- sql 语句 截取字符串的两种方案
方案一:使用内置的函数 SUBSTRING,CHARINDEX,LEN三个内置函数 理论: SUBSTRING语法 SUBSTRING ( value_expression , start_exp ...
- SQL Server截取字符串
--SQL Server截取字符串 , Len('hello@163.com')) ,charindex('.','hello@163.com'))
- 在论坛中出现的比较难的sql问题:1(字符串分拆+行转列问题 SQL遍历截取字符串)
原文:在论坛中出现的比较难的sql问题:1(字符串分拆+行转列问题 SQL遍历截取字符串) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方 ...
- mysql里面如何用sql语句让字符串转换为数字
sql语句将字符串转换为数字默认去掉单引号中的空格,遇到空格作为字符串截止, SELECT '123 and 1=1' +0 结果为123 MySQL里面如何用sql语句让字符串的‘123’转换为数字 ...
- SQL注入截取字符串函数
在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...
- Sql注入截取字符串常用函数
在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...
- 步步为营-104-SQL语句(截取字符串)
按照指定字符截取字符串,截取出300 业务需求:想比对图片中框线部分是否一致 第一步 从最后一个/截取到末尾 select top 1 reverse(substring(reverse(Proces ...
- SQL Server截取字符串和处理中文技巧
一 环境介绍 SQL Server PRINT @@VERSION MicrosoftSQLServer2012-11.0.2100.60(X64) Feb10201219:39:15 Copyri ...
- sql 语句系列(字符串的遍历嵌入删除与统计)[八百章之第十一章]
遍历字符串 我觉得首先要提出一个疑问: 一个数据库本身就是用于存储的,遍历字符串究竟有何意义? 先看如何实现的,毕竟sql service 是没有for循环,也没有loop和while的. selec ...
随机推荐
- Android网络编程系列之HTTP协议原理总结
前言 作为搞移动开发的我们,免不了与网络交互打交道.虽然市面上很多开源库都封装的比较到位,我们实现网络访问也轻车熟路.但还是十分有必要简要了解一下其中的原理,以便做到得心应手,也是通往高级开发工程师甚 ...
- Django 处理modelform错误信息
cp:https://blog.csdn.net/qq_34964399/article/details/79781071
- 简单的分页小demo
public class Demo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Sy ...
- Hibernate Criteria用法大全
1.标准查询简介 2.比较运算符 3.分页使用标准 4.排序结果 5.预测与聚合 6.关联 7. 动态关联抓取 8.查询示例 9.投影(Projections).聚合(aggregation)和分组( ...
- HTML table固定表头
最近尝试了几种HTML的table固定表头的方法..额...各有利弊,但很尴尬..... 1.thead和tbody的display设置为block; 这种可以实现,但是需要提前设置好每个th和td的 ...
- orcle 如何快速插入百万千万条数据
有时候做实验测试数据用到大量数据时可以用以下方法插入: 方法一:使用xmltable create table bqh8 as select rownum as id from xmltable('1 ...
- 微信小程序里解决app.js onLaunch事件与小程序页面的onLoad加载前后异常问题
使用 Promise 解决小程序页面因为需要app.js onLaunch 参数导致的请求失败 app.js onLaunch 的代码 "use strict"; Object.d ...
- Coursera-AndrewNg(吴恩达)机器学习笔记——第四周
神经网络 1.神经网络发展的动力:在逻辑回归解决复杂的分类问题时,我们使用属性的一些组合来构造新的属性(x12,x1x2,x22...),这样就会造成属性的数目n过多,带来了大量的运算,甚至造成过拟合 ...
- git 学习汇总
生成gitignore 文件: https://gitignore.io/ git 版本回退 git reset --hard HEAD^ 上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然 ...
- Apache Kafka系列(一) 起步
Apache Kafka系列(一) 起步 Apache Kafka系列(二) 命令行工具(CLI) Apache Kafka系列(三) Java API使用 Apache Kafka系列(四) 多线程 ...