Convert timestamp to date in Oracle SQL(在 Oracle SQL 中将时间戳转换为日期)
问题描述
我们如何将时间戳转换为日期?
How can we convert timestamp to date?
该表有一个字段,start_ts,其格式为 timestamp:
The table has a field, start_ts which is of the timestamp format:
'05/13/2016 4:58:11.123456 PM'
我需要查询表格并找到表格中的最大值和最小值timestamp,但我不能.
I need to query the table and find the maximum and min timestamp in the table but I'm not able to.
Select max(start_ts)
from db
where cast(start_ts as date) = '13-may-2016'
但是查询没有返回任何值.
But the query is not returning any values.
请帮我找出日期的最大时间戳.
Please help me in finding the max timestamp for a date.
推荐答案
CAST(timestamp_expression AS DATE)
例如,查询是:SELECT CAST(SYSTIMESTAMP AS DATE) FROM dual;
这篇关于在 Oracle SQL 中将时间戳转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Oracle SQL 中将时间戳转换为日期
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
