MySQL5.6中date和string的转换和比较
Conversion & Comparison, involving strings and dates in MySQL 5.6
The following rules describe how conversion occurs for comparison operations:
- If one or both arguments are NULL, the result of the comparison is NULL, except for the NULL-safe <=> equality comparison operator. For NULL <=> NULL, the result is true. No conversion is needed.
- If both arguments in a comparison operation are strings, they are compared as strings.
- If both arguments are integers, they are compared as integers.
- Hexadecimal values are treated as binary strings if not compared to a number.
- If one of the arguments is a TIMESTAMP or DATETIME column and the other argument is a constant, the constant is converted to a timestamp before the comparison is performed. This is done to be more ODBC-friendly. This is not done for the arguments to IN(). To be safe, always use complete datetime, date, or time strings when doing comparisons. For example, to achieve best results when using BETWEEN with date or time values, use CAST() to explicitly convert the values to the desired data type.
A single-row subquery from a table or tables is not considered a constant. For example, if a subquery returns an integer to be compared to a DATETIME value, the comparison is done as two integers. The integer is not converted to a temporal value. To compare the operands as DATETIME values, use CAST() to explicitly convert the subquery value to DATETIME.- If one of the arguments is a decimal value, comparison depends on the other argument. The arguments are compared as decimal values if the other argument is a decimal or integer value, or as floating-point values if the other argument is a floating-point value.
- In all other cases, the arguments are compared as floating-point (real) numbers.
MySQL5.6中date和string的转换和比较的更多相关文章
- Java Date,long,String 日期转换
1.java.util.Date类型转换成long类型java.util.Date dt = new Date();System.out.println(dt.toString()); //java. ...
- java中Date与String的相互转化
1:大体思路 这种转换要用到java.text.SimpleDateFormat类 字符串转换成日期类型: 方法1: 也是最简单的方法 Date date=new Date("2008-04 ...
- Java中Date、String、Calendar类型之间的转化
1.Calendar 转化 String //获取当前时间的具体情况,如年,月,日,week,date,分,秒等 Calendar calendat = Calendar.getInstanc ...
- iOS中date和string的相互转换
必须知道的内容 G: 公元时代,例如AD公元 yy: 年的后2位 yyyy: 完整年 MM: 月,显示为1-12 MMM: 月,显示为英文月份简写,如 Jan ...
- Date与String互相转换及日期的大小比较
private static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; /** * String转Date * * @param ...
- mybatis与mysql中的Date和String之间转换
在javaweb开发过程中,难免会使用日期类型,在持久化时java的日期格式可以是String,Date.mysql格式可以是varchar,datetime.他们之间如何进行相互转化? 1 java ...
- Java中int和String互相转换的多种方法
1 如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Integer.parseInt([String]); 或 i = Integer.parseInt([ ...
- Java中Date与String的相互转换
我们在注册网站的时候,往往需要填写个人信息,如姓名,年龄,出生日期等,在页面上的出生日期的值传递到后台的时候是一个字符串,而我们存入数据库的时候确需要一个日期类型,反过来,在页面上显示的时候,需要从数 ...
- 关于date和String互相转换的问题
其实原理很简单,就是将String类型的变量使用SimpleDateFormat来转换成Date,然后用getTime()方法比较 SimpleDateFormat sdf = new SimpleD ...
随机推荐
- [flask实践] 解决mysql数据库不支持中文的问题
接上一篇文章,在解决了mysql+flask环境配置问题之后,往数据库存中文字符串会报1366错误,提示不正确的字符.继而发现默认的mysql采用了Latin1字符集,这种编码是不支持中文的. 如果想 ...
- 外部地址访问xampp
默认情况下xampp只能访问本地服务器的地址.即localhost如果需要在外部机器访问XAMPP,则需要修改配置:找到xampp的文件夹,找到apache文件夹中的conf->extra-&g ...
- base64位加密解密
1.base64位加密base64是用于传输8Bit字节代码,由上图的编码表可以知道,编码后的内容只包含这64个字符类型,所以称为base64编码 2.编码过程 : 首先将待编码的内容转换成8位二进制 ...
- codeblocks+mbedtls库配置
网上都没有找到window下mbedtls的相关配置,或许是太简单了.希望可以帮助那些像我这样的小白一枚. 下载 github的下载:https://github.com/ARMmbed/mbedtl ...
- 原生javascript选项卡
js选项卡是一个常用的实现.这里我们将用原生js来将其给予实现. 首先html代码: <div id="container"> <input type=" ...
- 使用superMap实现点标注和区域着色
1.定义html文件,引入superMap的js和theme文件: <script src='${_ctxPath }/statics/js/superMap/SuperMap.Include. ...
- cookie大小
一.浏览器允许每个域名所包含的cookie数: Microsoft指出InternetExplorer8增加cookie限制为每个域名50个,但IE7似乎也允许每个域名50个cookie. Firef ...
- ConcurrentHashMap\HashMap put操作时key为什么要rehash
参考java并发编程的艺术一书中,对ConcurrentHashMap的讲解 ConcurrentHashMap使用的是分段锁Segment来保证不同的Segment区域互相不干扰,不存在锁竞争关系, ...
- django1.11如何实时访问mysql数据库
前几天,一直在研究django框架,发现它自身封装了很多有用的API,很有意思.比如,数据库操作基本的创表,查询,插值,更新,删除都有,很方便,再加上json库可以直接将数据json化,通过服务器传给 ...
- JWT.NET的使用
JWT是什么 JWT全称是Json Web Token,是一种用于双方之间传递安全信息的简洁的.URL安全的表述性声明规范.JWT作为一个开放的标准( RFC 7519 ),定义了一种简洁的,自包含的 ...