簡體   English   中英

日期字段上的to_char給出了意外結果

[英]to_char on a date field giving unexpected results

看看下面的兩個語句,誰能告訴我為什么我從第二個語句中得到的時間是“ 11:07”。 考慮到第一條語句返回23:00,我預計時間為“ 11:00 PM”。

 select early_shpdte
   from shipment
  where ship_id = '3644783_02_94874_5835330-01'

結果:07-09-2019 23:00:00

 select to_char(early_shpdte, 'MM/DD/YYYY HH:MM AM')
   from shipment
  where ship_id = '3644783_02_94874_5835330-01'

結果:07/09/2019 11:07 PM

您已使用MM兩次,因此時間部分中的“分鍾”值實際上是月份數。 你要:

select to_char(early_shpdte, 'MM/DD/YYYY HH:MI AM')
--------------------------------------------^^
  from shipment
 where ship_id = '3644783_02_94874_5835330-01'

格式模型元素在文檔中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM