Open hab6 opened 1 year ago
[clach04@usau-engfs01 ~]$ cal 1988
1988
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4 5
3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12
10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19
17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26
24 25 26 27 28 29 30 28 29 27 28 29 30 31
31
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 7 1 2 3 4
3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11
10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18
17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25
24 25 26 27 28 29 30 29 30 31 26 27 28 29 30
July August September
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3
3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10
10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17
17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24
24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30
31
October November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2 3
2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10
9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17
16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24
23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31
30 31
The ISO 8601 rule is: The first week of the year is the week containing the first Thursday. So if January 1 falls on a Friday, it belongs to the last week of the previous year. If December 31 falls on a Wednesday, it belongs to week 01 of the following year.
from https://myweb.ecu.edu/mccartyr/aboutwdc.htm and also https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-weeknum
The following Tableau TDVT test case fails using the Actian JDBC and ODBC connector code due to not matching any of the sets of expected values as defined in datename.sow.week, datename.sow.week.1, datename.sow.week.2.
Test Case:
DATENAME('week', [date2], 'monday')
Actual:1,11,16,17,21,23,28,29,32,36,37,44,5,6
Expected:2,11,17,18,22,23,29,30,33,36,37,38,45,5,7
_(Actual & Expected values from a typical TDVT report: test_resultscombined.csv)From dialect.tdd, the function
<date-function name='DATENAME' return-type='str'>
is defined with 5 different implementations, having these formulas for calculating the "week" part of the date:Reference calculations and expected values for "week" of the Calcs.date2 column using various methods
JDBC & ODBC
week, week.1, week.2
Queries for the values in the above table
SELECT CAST(Cast(WEEK(date2,0) AS INTEGER) AS VARCHAR(3)) AS WEEK FROM Calcs Calcs order by 1
SELECT CAST(Cast(WEEK(date2,1) AS INTEGER) AS VARCHAR(3)) AS WEEK FROM Calcs Calcs order by 1
SELECT CAST(Cast(WEEK_ISO(date2) AS INTEGER) AS VARCHAR(3)) AS WEEK FROM Calcs Calcs order by 1
Summary
The purpose of including the above table with data is to provide detailed data to help decide which calculation method aligns best with the true results for test case DATENAME('week', [date2], 'monday'). It appears that queries B and C are probably most accurate according to results from an arbitrary web site called PlanetCalc for calculating week of the year for given dates.