date '0001-01-01'からの日数
Oracle XEとC#4とでは、0001/1/1からの日数に少し差があるみたいなんです。何ででしょうか?
Oracle
> select '0101' n, date '0101-01-01' - date '0001-01-01' m from dual
> union all select '0201' n, date '0201-01-01' - date '0001-01-01' m from dual
> ~
> union all select '2001' n, date '2001-01-01' - date '0001-01-01' m from dual
> union all select '2010' n, date '2010-01-01' - date '0001-01-01' m from dual
C#
> static void Main(string[] args) {
> DateTime z = new DateTime(0, DateTimeKind.Utc);
> foreach (int i in new int[] { 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001,
> 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901, 1970, 2001, 2010, }) {
> TimeSpan s = new DateTime(i, 01, 01, 0, 0, 0, DateTimeKind.Utc) - z;
> Console.WriteLine("{0:0000}{1, 10}", i, s.TotalDays);
> }
> Console.ReadLine();
> }
| | C# | Oracle | 差 |
| 0101/01/01 | 36,524 | 36,525 | -1 |
| 0201/01/01 | 73,048 | 73,050 | -2 |
| 0301/01/01 | 109,572 | 109,575 | -3 |
| 0401/01/01 | 146,097 | 146,100 | -3 |
| 0501/01/01 | 182,621 | 182,625 | -4 |
| 0601/01/01 | 219,145 | 219,150 | -5 |
| 0701/01/01 | 255,669 | 255,675 | -6 |
| 0801/01/01 | 292,194 | 292,200 | -6 |
| 0901/01/01 | 328,718 | 328,725 | -7 |
| 1001/01/01 | 365,242 | 365,250 | -8 |
| 1101/01/01 | 401,766 | 401,775 | -9 |
| 1201/01/01 | 438,291 | 438,300 | -9 |
| 1301/01/01 | 474,815 | 474,825 | -10 |
| 1401/01/01 | 511,339 | 511,350 | -11 |
| 1501/01/01 | 547,863 | 547,875 | -12 |
| 1601/01/01 | 584,388 | 584,390 | -2 |
| 1701/01/01 | 620,912 | 620,914 | -2 |
| 1801/01/01 | 657,436 | 657,438 | -2 |
| 1901/01/01 | 693,960 | 693,962 | -2 |
| 1970/01/01 | 719,162 | 719,164 | -2 |
| 2001/01/01 | 730,485 | 730,487 | -2 |
| 2010/01/01 | 733,772 | 733,774 | -2 |
もしかして、どこか間違ってますか?
お礼
ありがとうございました。