首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

mysql计算时间

一、MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+ | now() | +---------------------+ | 2008-08-08 22:20:46 | +---------------------+ 除了 now() 函数能获得当前的日期时间外,MySQL 中还有下面的函数: current_timestamp() ,current_timestamp ,localtime() ,localtime ,localtimestamp -- (v4.0.6) ,localtimestamp() -- (v4.0.6) 这些日期时间函数,都等同于 now()。鉴于 now() 函数简短易记,建议总是使用 now() 来替代上面列出的函数。 1.2 获得当前日期+时间(date + time)函数:sysdate() sysdate() 日期时间函数跟 now() 类似,不同之处在于:now() 在执行开始时值就得到了, sysdate() 在函数执行时动态得到值。看下面的例子就明白了: mysql> select now(), sleep(3), now(); +---------------------+----------+---------------------+ | now() | sleep(3) | now() | +---------------------+----------+---------------------+ | 2008-08-08 22:28:21 | 0 | 2008-08-08 22:28:21 | +---------------------+----------+---------------------+ mysql> select sysdate(), sleep(3), sysdate(); +---------------------+----------+---------------------+ | sysdate() | sleep(3) | sysdate() | +---------------------+----------+---------------------+ | 2008-08-08 22:28:41 | 0 | 2008-08-08 22:28:44 | +---------------------+----------+---------------------+ 可以看到,虽然中途 sleep 3 秒,但 now() 函数两次的时间值是相同的; sysdate() 函数两次得到的时间值相差 3 秒。MySQL Manual 中是这样描述 sysdate() 的:Return the time at which the function executes。 sysdate() 日期时间函数,一般情况下很少用到。 2. 获得当前日期(date)函数:curdate() mysql> select curdate(); +------------+ | curdate() | +------------+ | 2008-08-08 | +------------+ 其中,下面的两个日期函数等同于 curdate(): current_date() ,current_date 3. 获得当前时间(time)函数:curtime() mysql> select curtime(); +-----------+ | curtime() | +-----------+ | 22:41:30 | +-----------+ 其中,下面的两个时间函数等同于 curtime(): current_time() ,current_time 4. 获得当前 UTC 日期时间函数:utc_date(), utc_time(), utc_timestamp() mysql> select utc_timestamp(), utc_date(), utc_time(), now() +---------------------+------------+------------+---------------------+ | utc_timestamp() | utc_date() | utc_time() | now() | +---------------------+------------+------------+----------

02

C/C++语言 常用头文件及函数

#include <assert.h>    //设定插入点 #include <ctype.h>     //字符处理 #include <errno.h>     //定义错误码 #include <float.h>     //浮点数处理 #include <iso646.h> //对应各种运算符的宏 #include <limits.h>    //定义各种数据类型最值的常量 #include <locale.h>    //定义本地化C函数 #include <math.h>     //定义数学函数 #include <setjmp.h> //异常处理支持 #include <signal.h> //信号机制支持 #include <stdarg.h> //不定参数列表支持 #include <stddef.h> //常用常量 #include <stdio.h>     //定义输入/输出函数 #include <stdlib.h>    //定义杂项函数及内存分配函数 #include <string.h>    //字符串处理 #include <time.h>     //定义关于时间的函数 #include <wchar.h>     //宽字符处理及输入/输出 #include <wctype.h>    //宽字符分类

00

Python常识

一、强类型语言与弱类型语言 1、强类型语言 强类型语言是一种总是强制类型定义的语言,要求变量的使用要严格符合定义,所有变量都必须先定义后使用。例如:java、.NET、C++ 2、弱类型语言 某一个变量被定义类型,该变量可以根据环境变化自动进行转换,不需要经过显性强制转换。例如:vb 、PHP、javascript、Python 二、Python注释 1、# 单行注释 例 # 你好 2、''' 或者""" 用于多行注释 例 ''' import os hello world ''' 或 """ import os hello world """ 三、Python代码规范 1、每个 import 语句一次只导入一个模块 import os import sys #正确 import os,sys #错误 2、不要在行尾添加分号 import os; #错误 import os #正确 3、每行建议不超过 80 个字符,如果超过,建议使用小括号将多行内容隐式的连接起来 s=("C语言中文网是中国领先的C语言程序设计专业网站," "提供C语言入门经典教程、C语言编译器、C语言函数手册等。") 4、在运算符两侧、函数参数之间以及逗号两侧,建议使用空格进行分隔 四、Python标识符 标识符就是一个名字,它的主要作用就是作为变量、函数、类、模块以及其他对象的名称。 1、标识符是由字符、下划线和数字组成,但第一个字符不能是数字。 2、标识符不能和 Python 中的保留字相同。 3、标识符中,不能包含空格、@、% 以及 $ 等特殊字符。 4、标识符中的字母是严格区分大小写的 5、以下划线开头的标识符有特殊含义,非特定场景需要,应避免使用以下划线开头的标识符 例如: 1)、以单下划线开头的标识符(如_width),表示不能直接访问的类属性,其 无法通过 from...import 的方式导入; 2)、以双下划线开头的标识符(如 __add)表示类的私有成员;

01
领券