• Revenant (8/10/2011)


    Tom.Thomson (8/10/2011)


    . . .

    Not in most countries except Britain (note single t), in all countries including Britain. Datetime2 uses the Gregorian calendar, not any other calendar, so it is not a locale dependent type.

    Hmm... maybe it is not quite Gregorian. If you run this, --

    DECLARE @type2 DATETIME2(7) = '1582-10-10';

    PRINT DATEPART( dw, @type2 );

    you will get 1, i.e., Monday, but that is wrong because there was no October 10 in 1582.

    Actually if you have Monday as day 1 you will get 7, because that date is a Sunday in the Gregorian calendar. I suspect you have the US default (datefirst = 7, so dw=1 on Sunday), since you presumably got 1.

    I guess you and I mean different things by "The Gregorian Calendar"; if "Gregorian Calendar" means the national calendar of the United Kingdom of Poland and Lithuania, or some of the Italian states, or Spain, or Portugal that date didn't exist (in the national calendars of everywhere else in the Western world it did). If you mean the calendar using the 365.2525 day year in common use throughout the western world, in which today is 10 August 2011, extended backwards and forwards according to its regular rules without limit (which is the most common meaning, I believe) 10 Oct 1582 certainly does exist in that calendar.

    Using calendars of particular nations can lead to strange results. For example in England the months of January and February did not legally exist in 1751, but they did exist in Scotland (Scottish Jan 1751 was English Jan 1750; almost everyone in England already used the Scottish dating for everything except legal documents and taxation; it was just the legal system in England that was out of step). Scotland had begun the year on 1 Jan since 1600, while up to and including 1751 England began the year on 25th March. That's where we get our 6 April to 5 April taxation year from - it was 5 April to 4 April from 1752 to 1799, then from 6 April to 5 April from 1800 to 1899 in order to retain the same Julian date; but it wasn't adjusted in 1900, which was the next year when an adjustment would have been needed to maintain the Julian connection (whether because the 1751 act was interpreted differently or because the powers that be had forgotten that that act had been interpreted in 1800 as demanding such an adjustment).

    Tom