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

大数据之Hive:Hive中week相关的几个函数

目录

  • 1.dayofweek函数
  • 2.weekday函数
  • 3.weekofyear函数

1.dayofweek函数

功能:统计某天为星期几

dayofweek(date) - Returns the day of the week for date/timestamp (1 = Sunday, 2 = Monday, ..., 7 = Saturday).

dayofweek返回值为:1-7,1 = 星期日, 2 = 星期一, …, 7 = 星期六,从星期日开始

示例:

SELECT dayofweek('2025-07-15');  ---3(星期二)

2.weekday函数

功能:统计某天为星期几

weekday(date) - Returns the day of the week for date/timestamp (0 = Monday, 1 = Tuesday, ..., 6 = Sunday).

weekday返回值为:0-6,0 = 星期一, 1 = 星期二, …, 6= 星期日,从星期一开始
示例:

select weekday('2025-07-15');  ---1(星期二)

3.weekofyear函数

功能统计:某天为某年的第几周

weekofyear(date) - Returns the week of the year of the given date. A week is considered to start on a Monday and week 1 is the first week with >3 days.
select weekofyear('2025-07-15') --29
http://www.xdnf.cn/news/1170793.html

相关文章:

  • 微调大语言模型(LLM)有多难?
  • SpringBoot全局异常报错处理和信息返回
  • Vue 脚手架基础特性
  • Maven 环境配置全攻略:从入门到实战
  • Typecho三种版权保护方法对比与实战指南
  • 渗透部分总结
  • 如何把jar包打成docker镜像(SpringBoot项目打包成Docker )部署到Linux
  • 本地代理和服务器代理区别
  • 【MyBatisPlus】一文讲清 MyBatisPlus 基本原理及基本使用方式
  • NumPy库使用教学,简单详细。
  • allegro 16.6配置CIS库报错 ORCIS-6129 ORCIS-6469
  • Matplotlib绘制各种图参考
  • 时序数据库IoTDB好不好?
  • 在 Linux 系统中基于 Nginx 搭建 openlab 网站及子页面
  • 浅谈——C++和C#差异
  • 从 COLMAP 到 3D Gaussian Splatting
  • 【面试】Redis分布式ID与锁的底层博弈:高并发下的陷阱与破局之道
  • 机器人氩弧焊保护气降成本的方法
  • kafka主题管理详解 - kafka-topics.sh
  • 苹果app应用ipa文件程序开发后如何运行到苹果iOS真机上测试?
  • IntelliJ IDEA (2024.3.1)优雅导入 Maven 项目的两种方式详解
  • 【小学】小学学习资料合集(不定时更新,有需要及时保存,避免失效)
  • LNMP平台部署
  • 设计模式——责任链模式
  • 欧式装修颜色要怎么搭配?
  • Linux研学-MySQL安装
  • C# 类 封装 属性 练习题
  • 暑假算法训练.6
  • [LLM]Synthetic Visual Genome
  • pluto example, heat-1d优化分析