I drilled in to spot check some tickets and found that my created attribute was displaying the last time the ticket was updated, whether it was by the updater I am filtering for or not. I did not expect to see multiple weeks of "Update - Week of year" within each "Ticket Updated Week by Start of Week". When I did that it returned the report below. Week number update#I added Ticket Update attributes on one card to see what would return. I noticed some odd returns and the numbers not line up when I simply used "Update - Week of year". Return time?.Is it possible to use this formula to view ticket update week, by start of week? And for it to display based on individual updates and not the latest update? I used the below formula and am seeing some odd returns:ĭATE_FORMAT(START_OF_WEEK_MONDAY(),"YYYY-MM-dd") Public static string GetIso8601WeekAndYearString(this DateTime? time) Int year = weekNum = 52 & d.Month = 1 ? d.Year - 1 : d.Year Ĭonsole.WriteLine("Year: " var d = new DateTime(2012, 12, 31) ĬultureInfo cul = CultureInfo.CurrentCulture January 1st (sat) was the first one week day, and 31st December (sun) was the second one week day. It must be a leap year too.įor example, the year 2000 had 54 weeks. Happens every 28 years when the 1st of January and the 31st of December are treated as separate weeks. Ask the week number for the 1st of January and you'll get back 52 as it is considered part of 2011 last's week. Europe (Monday -> Sunday): January 2dn () is the first monday, so this is the first day of the first week. Last two days of this year (Sunday + Monday) make up their own short week.Ĭheck your current Culture's settings to see what it uses as the first day of the week.Īs you see it's normal to get 53 as a result. US (Sunday -> Saturday): 52 weeks + one short 2 day week for &.How many weeks there are really depends on the starting day of your week. Are these extra days counted as separate weeks of their own? So for each year you have at least one an extra day. Week number full#Each year has 52 full weeks + 1 or +2 (leap year) days extra. There can be more than 52 weeks in a year. This presumes that weeks start with Monday. Week number iso#Update The following method actually returns -12-31 which is correct in ISO 8601 (e.g. In the article there is also a simple function to get the correct ISO 8601 week number for the last week of the year. Net allow weeks to be split across years while the ISO standard does not. You can refer to this article in MSDN Blog for a better explanation: " ISO 8601 Week of Year format in Microsoft. Return (time, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday) Īs noted in this MSDN page there is a slight difference between ISO8601 week and. If (day >= DayOfWeek.Monday & day <= DayOfWeek.Wednesday) be the same week# as whatever Thursday, Friday or Saturday are,ĭayOfWeek day = (time) If its Monday, Tuesday or Wednesday, then it'll Public static int GetIso8601WeekOfYear(DateTime time) Week 1 is the 1st week of the year with a Thursday in it. In other words, my problem was that my methods were not following the ISO-8601 standard. The following method actually returns 1 when date is. We can turn a week number into a date using the WEEKNUM function. Int weekNum = (dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday) Solution 3: CultureInfo ciCurr = CultureInfo.CurrentCulture Solution 2: return new GregorianCalendar(GregorianCalendarTypes.Localized).GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday) Return cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek) Here are some of the methods, that I have tried:įrom the MDSN Library: DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo is Monday, therefore it should be Week 1, but every method I tried gives me 53. I have Googled a lot and found a lot of solutions, but none of them give me the correct week number for the.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |