Chinaunix首页 | 论坛 | 博客
  • 博客访问: 127563
  • 博文数量: 161
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: -30
  • 用 户 组: 普通用户
  • 注册时间: 2017-09-21 21:45
文章分类
文章存档

2009年(1)

2008年(74)

2007年(48)

2006年(38)

我的朋友

分类: Oracle

2008-12-18 17:00:42

How does week numbering work & why do (some) years have 53 weeks?

As can be seen in the link above, Oracle has 2 format masks that return a (different) week number for a input date.
The WW format mask very simply calculates week 1 starting on the first day of the year and continues to the seventh day of the year, etc. etc. Because a year consists of 365 or 366 days this means that 31-DEC (and in leap years 30-DEC) falls in week 53.
The IW format mask follows ISO-8601 to assign a number to a week of the year. The ISO week always starts on a Monday (this is the international standard, different than the US standard!), the week that contains the first Thursday in January is week nr 1. All previous days of that week (the last days of the preceding year) also belong to "week 1" of that year.
This means that in the ISO calendar there is only a week 53 if the 1-JAN of that year was between Thursday and Sunday (or Wednesday in leap years). For example 1-JAN-2009 falls on a Thursday, making that whole week "week 1 of year 2009", 1-JAN-2010 falls on a Friday, which means that that week is still part of the previous year 2009, making that the 53rd week of 2009.

 

另外附上用於日期和時間的Format:

FORMAT 描述
HH 一天的小時數 (01-12)
HH12 一天的小時數 (01-12)
HH24 一天的小時數 (00-23)
MI 分鐘 (00-59)
SS 秒 (00-59)
MS 毫秒 (000-999)
US 微秒 (000000-999999)
SSSS 午夜後的秒 (0-86399)
AMA.M.PMP.M. 正午標識(大寫)
ama.m.pmp.m. 正午標識(小寫)
Y,YYY 帶逗號的年(4 和更多位)
YYYY 年(4和更多位)
YYY 年的後三位
YY 年的後兩位
Y 年的最後一位
IYYY ISO 年(4位或更多位)
IYY ISO 年的最後 3 位
IY ISO 年的最後 2 位
I ISO 年的最後一位
BCB.C.ADA.D. 紀元標識(大寫)
bcb.c.ada.d. 紀元標識(小寫)
MONTH 全長大寫月份名(空白填充為9字元)
Month 全長混合大小寫月份名(空白填充為9字元)
month 全長小寫月份名(空白填充為9字元)
MON 大寫縮寫月份名(3字元)
Mon 縮寫混合大小寫月份名(3字元)
mon 小寫縮寫月份名(3字元)
MM 月份號(01-12)
DAY 全長大寫日期名(空白填充為9字元)
Day 全長混合大小寫日期名(空白填充為9字元)
day 全長小寫日期名(空白填充為9字元)
DY 縮寫大寫日期名(3字元)
Dy 縮寫混合大小寫日期名(3字元)
dy 縮寫小寫日期名(3字元)
DDD 一年裏的日子(001-366)
DD 一個月裏的日子(01-31)
D 一周裏的日子(1-7;周日是1)
W 一個月裏的周數(1-5)(第一周從該月第一天開始)
WW 一年裏的周數(1-53)(第一周從該年的第一天開始)
IW ISO 一年裏的周數(第一個星期四在第一周裏)
CC 世紀(2 位)
J 儒略日(自西元前4712年1月1日來的天數)
Q 季度
RM 羅馬數字的月份(I-XII;I=JAN)(大寫)
rm 羅馬數字的月份(I-XII;I=JAN)(小寫)
TZ 時區名 (大寫)
tz 時區名 (小寫)

阅读(1587) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~