---
title: "oracle to_date 函数"
author: "wyl232"
date: "2009-03-05T16:58:17Z"
tags: ["Oracle", "SQL"]
slug: "oracle-to-date"
draft: false
lastmod: "2009-03-05T16:58:17Z"
id: 344017
url: "https://wyl232.iteye.com/blog/344017"
---

如：select **to\_date**('2005-01-01 13:14:20','yyyy-MM-dd HH24:mm:ss') from dual;  
原因是SQL中不区分大小写，MM和mm被认为是相同的格式代码，所以**Oracle**的SQL采用了mi代替分钟。  
select **to\_date**('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual;  
二、另要以24小时的形式显示出来要用HH24  
select to\_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;//mi是分钟  
select to\_char(sysdate,'yyyy-MM-dd HH24:mm:ss') from dual;//mm会显示月份