date函数

HIve高级函数

本小妞迷上赌 提交于 2019-11-30 06:27:05
最近使用了hive一些高级函数,在此记录一下 一:Hive是什么 Hive是面向大数据的数据仓库,是一种将SQL转换为mapreduce的工具。 二:hive表 内表、外表、分区、桶表、location、压缩这些都是表的属性,每个之间没有什么关系(内表外表不可以同时存在)。也就是说一个表既可以是内表,也可是分区表桶表,也可以规定存放路径还可压缩 内表 内表其实就是将拷贝到Hive的目录下,表和数据关联,表删除数据删除。 create table if not exists table_test ( aa string ) row format delimited fields terminated by '\001' location '/hive/table/table_test';       以上的语句就是建一个内表,一行是一条记录,字段之间按照\001分割,数据最终存放的位置是/hive/table/table_test。   装载数据:     insert into table_test     select aa from table_aa;     或     load data inpath '/hive/date/table_test' overwrite into table table_test;(overwrite是覆盖数据,可去掉) 外表

javascript中的Math数学和Date日期

此生再无相见时 提交于 2019-11-30 05:50:40
Math数学 Math.PI; 圆周率常量 Math.E; 自然对数常量 Math.abs(-2); 绝对值 Math.pow(2,3); 次方、幂运算 等同于2**3 Math.sqrt(9); 开平方根 Math.pow(9,1/3; 开任意平方根 Math.sin(30*Math.PI/180); 正弦 Math.max(1,8,2); 最大值 Math.min(5,2,7); 最小值 Math.round(3,5); 四舍五入 Math.floor(3.6); 向下取整 Math.ceil(3.4); 向上取整 Math.random(); 随机数,返回[0,1]的浮点数有人就是小数 Date日期 1 .当前时间 var now=new Date(); 2 .生成已知时间的日期对象 var yesterday=new Date(); 3 .时间截格式 对象时间 减 1970年1月1日0点0分0秒 的秒数,前十位是秒数后三位毫秒。 缺点:不自然,表现时间范围有限。 优点:日期加减、比较早晚 方便。 now.getTime(); Date.parse(now); 4 .取年、月、日、时、分、秒 now.getFullYear(); now.getMonth(); now.getDay(); now.getHours(); now.getMinutes(); now

Mate

只谈情不闲聊 提交于 2019-11-30 03:57:07
1.oninput:只要用户输入就会触发 2.获取输入框的值:str=document.getElementById('id名‘) ;let x=str.value(标准写法) 3.Math是js的原生对象或内置对象;是很多变量和很多方法的集合。 typeof Math://object 4.Math的方法: Math对象的属性,提供以下一些数学常数。(了解) Math.E:常数e。 Math.PI:常数 Pi。 Math.abs():返回参数的绝对值 Math.max(1,2,3,4);一个参数不传会得到的结果是-infinity;传多个参数,返回参数中的最大值; Math.min(1,2,3,4);一个参数不传会得到的结果是infinity;传多个参数,返回参数中的最小值; Math.max()里面也可以加一个数组但在前面要加… 也可以求数组中的最大值Math.max(…arr1); Math.floor方法小于参数值的最大整数(地板值)。 Math.floor(3.2) // 3 Math.floor(-3.2) // -4 Math.ceil方法返回大于参数值的最小整数(天花板值)。 Math.ceil(3.2) // 4 Math.ceil(-3.2) // -3 Math.round()用于四舍五入; Math.round(0.1) // 0Math.round(0.5

1891-2100年php日历代码

…衆ロ難τιáo~ 提交于 2019-11-30 03:26:12
<?php /* * 1891-2100年 农历 节气 节日 */ header("Content-Type:text/html;charset=utf-8"); class Lunar { var $MIN_YEAR = 1891; var $MAX_YEAR = 2100; var $lunarInfo = array( array(0,2,9,21936),array(6,1,30,9656),array(0,2,17,9584),array(0,2,6,21168),array(5,1,26,43344),array(0,2,13,59728), array(0,2,2,27296),array(3,1,22,44368),array(0,2,10,43856),array(8,1,30,19304),array(0,2,19,19168),array(0,2,8,42352), array(5,1,29,21096),array(0,2,16,53856),array(0,2,4,55632),array(4,1,25,27304),array(0,2,13,22176),array(0,2,2,39632), array(2,1,22,19176),array(0,2,10,19168),array(6,1,30,42200),array(0,2,18,42192)

js中Date的构造函数解读

风格不统一 提交于 2019-11-30 03:25:47
javascript中的内置对象是我们经常会用到的,那么今天我们就来说说Date的四种构造方法吧 一、new Date()    这是我们最常使用也最熟悉不过的Date对象的构造方法了,通过无参数的构造函数我们可以默认获取到一个代表实例化时的Date对象 var now = new Date(); console.log(now) //Thu Sep 19 2019 16:13:08 GMT+0800 (中国标准时间) 二、new Date(value)    这个构造方法的参数是一个Number型,表示自1970年1月1日00:00:00 UTC(the Unix epoch)以来的毫秒数,忽略了闰秒。这个方法中可以用整型,也可以用浮点型,不过浮点型后面的小数点后的尾数一般会被忽略就是了。虽然在node环境(v10.15.3)下参数的确是从00:00:00时分开始计数,但是,通过实测发现在部分浏览器环境(在Edge,Chrome下如此)下参数是却从08:00:00开始计数,如下代码所示: //浏览器 var time1 = new Date(1000); var time2 = new Date(2000.2); var time3 = new Date(2000.8); console.log(time1); //Thu Jan 01 1970 08:00:01 GMT

JS格式化数字金额用逗号隔开保留两位小数(转)

给你一囗甜甜゛ 提交于 2019-11-30 02:59:01
JS格式化数字金额只留两位小数。写了个格式化函数。 可以控制小数位数,自动四舍五入。 js 格式化金额 的实例详解。 例如: 12345格式化为12,345.00 12345.6格式化为12,345.60 12345.67格式化为 12,345.67 只留两位小数。 回来后写了个格式化函数。可以控制小数位数,自动四舍五入。 代码: function fmoney ( s , n ) { n = n > 0 & & n < = 20 ? n : 2 ; s = parseFloat ( ( s + "" ) . replace ( / [ ^ \ d\ . - ] / g , "" ) ) . toFixed ( n ) + "" ; var l = s . split ( "." ) [ 0 ] . split ( "" ) . reverse ( ) , r = s . split ( "." ) [ 1 ] ; t = "" ; for ( i = 0 ; i < l . length ; i + + ) { t + = l [ i ] + ( ( i + 1 ) % 3 = = 0 & & ( i + 1 ) ! = l . length ? "," : "" ) ; } return t . split ( "" ) . reverse ( ) . join ( "" )

Day54 Django功能内部源码和模版层

北战南征 提交于 2019-11-30 02:18:55
一.Django中内部源码 1.render内部原理 render返回一个html页面,并且还能够给该页面传数据 render内部原理 from django.template import Template,Context def index(request): temp = Template('<h1>{{ user }}</h1>') con = Context({"user":{"name":'sxc',"password":'123'}}) res = temp.render(con) print(res) return HttpResponse(res) 2.FBV与CBV 视图函数层不只是只有函数,也可以是类 FBV(基于函数的视图):面向函数式编程 CBV(基于类的视图):面向对象式编程 现在写一个CBV的小例子 视图函数层生成一个类 views层 from django.views import View class Login(View): def get(self,request): return render(request,'login.html') def post(self,request): return HttpResponse('收到了') urls中编写对应的视图函数对应关系 urls层 url(r'^login/', views.Login

MongoDB的Shell操作

纵然是瞬间 提交于 2019-11-30 02:15:29
前言 本文从介绍了MongoShell 的配置、脚本、数据类型和其他指令。 MongoShell - 简介 MongoShell是一个互动的JavaScript接口的MongoDB,可以使用MongoShell来查询和更新数据以及执行管理操作。 MongoShell是MongoDB发行版的一个组件, 安装并启动MongoDB后,将MongoShell连接到正在运行的MongoDB实例,MongoDB手册中的大多数示例使用 MongoShell,然而,许多驱动程序也提供了与MongoDB类似的接口。 启动MongoShell: 在启动MongoShell之前请确保MongoDB 实例在运行,在Terminal 中键入Mongo则可以直接启动。 示例代码: ➜ ~ mongo MongoDB shell version v3.4.3 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.3 Server has startup warnings: 2017-10-19T10:41:29.922+0800 I CONTROL [initandlisten] 2017-10-19T10:41:29.923+0800 I CONTROL [initandlisten] ** WARNING: Access

oracle中处理日期的方法

淺唱寂寞╮ 提交于 2019-11-30 00:35:50
1. 日期和字符转换函数用法(to_date,to_char ) select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss’) as nowTime from dual; //日期转化为字符串 select to_char(sysdate,‘yyyy’) as nowYear from dual; //获取时间的年 select to_char(sysdate,‘mm’) as nowMonth from dual; //获取时间的月 select to_char(sysdate,‘dd’) as nowDay from dual; //获取时间的日 select to_char(sysdate,‘hh24’) as nowHour from dual; //获取时间的时 select to_char(sysdate,‘mi’) as nowMinute from dual; //获取时间的分 select to_char(sysdate,‘ss’) as nowSecond from dual; //获取时间的秒 2. 字符串和时间互转 select to_date(‘2004-05-07 13:23:44’,‘yyyy-mm-dd hh24:mi:ss’) from dual select to_char( to_date(222,‘J’),

python 中的strptime()和strftime()

纵然是瞬间 提交于 2019-11-29 21:34:03
python 中的strptime()和strftime() 转自:https://blog.csdn.net/qq_39348113/article/details/82528851 strptime(): 功能:按照特定时间格式将字符串转换(解析)为时间类型。 示例如下: def date_try(date): date = datetime.datetime.strptime(date,'%Y-%m-%d') return date def main(): a = date_try('2016-02-29') print(a) main() 1 2 3 4 5 6 7 8 9 输出如下: 2016-02-29 00:00:00 Process finished with exit code 0 1 2 3 可见,在这段代码中,strptime()函数将字符串‘2016-02-29’解析为时间。 如果我将这段字符串改为‘2016-02-30’后,超出了2月份的天数极限,运行就会报错 def date_try(date): date = datetime.datetime.strptime(date,'%Y-%m-%d') return date def main(): a = date_try('2016-02-30') print(a) main() 1 2 3 4 5 6