Why does transposing array with dates in format dd/mm/yy change some dates to mm/dd/yy format?

后端 未结 3 1970
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 09:39

Behavior:

When I transpose a 1 dimensional array, containing dates, in order to print them to a sheet in it\'s entirety, some dates are changed from the dd/m

3条回答
  •  花落未央
    2021-01-07 10:21

    After doing some more research, I have found the following:

    It would seem that the Application.Transpose(arrDate) transposes not only the array, but also date values when they are stored as actual date.

    Consider the date , 42373 (January 4, 2016)

    • Debug.Print Format(CDate(42373), "mmmm d, yyyy")
      • produces januari 4, 2016
    • Debug.Print Application.Transpose(Format(CDate(42373), "mmmm d, yyyy"))
      • produces april 1, 2016

    It appears that a date value can be transposed when stored as an actual date. The transposing effectively reorders the date from day/month to month/day after which the the month becomes the day and the day becomes the month because the system still uses the day/month format. This can only be done if the day of the month is 12 or less, because after transposing the day becomes the month.

提交回复
热议问题