week-number

Get week number using date in python

六眼飞鱼酱① 提交于 2019-12-22 22:40:40
问题 Date is datetime.date(2013, 12, 30) I am trying to get week number using import datetime datetime.date(2013, 12, 30).isocalendar()[1] I am getting output as , 1 Why i am not getting week number of last year , instead i am getting week number of current year? Whats wrong i am doing here ? 回答1: You are doing nothing wrong, 2013/12/30 falls in week 1 of 2014, according to the ISO8601 week numbering standard: The ISO 8601 definition for week 01 is the week with the year's first Thursday in it.

Get week of month C# [duplicate]

我与影子孤独终老i 提交于 2019-12-21 20:38:55
问题 This question already has answers here : Calculate week of month in .NET (12 answers) Closed 5 years ago . I want to find a date are now on week number with c# desktop Application. I've been looking on google, but none that fit my needs. How do I get a week in a month as the example below? Example: I want January 6, 2014 = the first week of January January 30, 2014 = fourth week of January but 1 February 2014 = week 4 in January and 3 February 2014 was the first week in February 回答1: Here is

How to group by week in Entity Framework Core?

佐手、 提交于 2019-12-21 16:15:10
问题 In Entity Framework 6 I can use SqlFunctions.DatePart() method: var byWeek = data.GroupBy(x => SqlFunctions.DatePart("week", x.Date)); But these classes ( DbFunctions and SqlFunctions are not available in Entity Framework Core) (reference). So my question is How can I group by week in Entity Framework core? 回答1: My current workaround for the missing functionality is var firstMondayOfYear = this.GetFirstMondayOfYear(DateTime.Now.Year); var entries = this.entitiesService.FindForLastMonths(this

Group by Week of year (Week number) in Linq to SQL

拈花ヽ惹草 提交于 2019-12-19 03:23:02
问题 In regular SQL i could do something like SELECT * From T GROUP BY DATEPART(wk, T.Date) How can i do that in Linq to SQL ? The following don't work From F In DB.T Group R By DatePart(DateInterval.WeekOfYear, F.Date) Also don't work: From F In DB.T Group R By (F.Date.DayOfYear / 7) 回答1: Range variable name can be inferred only from a simple or qualified name with no arguments 回答2: LINQ to SQL does not support the Calendar.WeekOfYear method, but you could potentially create a TSQL function that

PHP date('W') vs MySQL YEARWEEK(now())

五迷三道 提交于 2019-12-18 15:01:12
问题 Can someone kindly explain me why these two give different results? I execute this with PHP. date("YW",mktime(0, 0, 0, 3, 22 , 2013)); // outputs 201312 And when I execute this with MySQL SELECT YEARWEEK(now()); // outputs 201311 回答1: You need to specify mode 3 on the mysql YEARWEEK call: SELECT YEARWEEK(now(),3); The PHP date() placeholder W returns the week number according to the ISO 8601 specification. That means weeks start on Monday (not Sunday), the first week of the year is number 1

Moment.js get the week number based on a specific day (also past years)

谁说胖子不能爱 提交于 2019-12-18 12:04:50
问题 How could I get from moment JS the week number from a date in the past only from a moment formatted object from a day selected? 回答1: $(document).ready(function(){ var weeknumber = moment("12-25-1995", "MM-DD-YYYY").week(); console.log(weeknumber); }); According momentjs docs: Because different locales define week of year numbering differently, Moment.js added moment#week to get/set the localized week of the year. The week of the year varies depending on which day is the first day of the week

Moment.js get the week number based on a specific day (also past years)

北慕城南 提交于 2019-12-18 12:04:47
问题 How could I get from moment JS the week number from a date in the past only from a moment formatted object from a day selected? 回答1: $(document).ready(function(){ var weeknumber = moment("12-25-1995", "MM-DD-YYYY").week(); console.log(weeknumber); }); According momentjs docs: Because different locales define week of year numbering differently, Moment.js added moment#week to get/set the localized week of the year. The week of the year varies depending on which day is the first day of the week

In .net, knowing the week number how can I get the weekdays date?

人盡茶涼 提交于 2019-12-17 23:25:48
问题 I want to create a function in C# which for a week number will return me the days, in that week. For instance for week number 40, how can I get the days: 4/10, 5/10, 6/10, 7/10, 8/10, 9/10, 10/10. Thank you in advance! 回答1: I think this should do what you want: public static DateTime[] WeekDays(int Year, int WeekNumber) { DateTime start = new DateTime(Year, 1, 1).AddDays(7 * WeekNumber); start = start.AddDays(-((int)start.DayOfWeek)); return Enumerable.Range(0, 7).Select(num => start.AddDays

ISO week number in CMD

给你一囗甜甜゛ 提交于 2019-12-17 19:44:45
问题 How can I determine the (ISO 8601) week number in a Windows batch file? Unfortunately WMIC PATH WIN32_LOCALTIME GET /FORMAT:LIST only has WeekInMonth ... I have found some very complex solutions. Is there no easier way? 回答1: You can use Ritchie Lawrences's Date Functions. It is maintained on Gitub. https://ritchielawrence.github.io/batchfunctionlibrary/ Here is the code. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :DateToWeek %yy% %mm% %dd% yn cw dw :: :: By:

System.Globalization.Calendar.GetWeekOfYear() returns odd results

守給你的承諾、 提交于 2019-12-17 12:46:13
问题 I'm in the middle of calculating week numbers for dates, but the System.Globalization.Calendar is returning odd results for (amongst other years) December 31st of year 2007 and 2012. Calendar calendar = CultureInfo.InvariantCulture.Calendar; var date = new DateTime(2007, 12, 29); for (int i = 0; i < 5; i++) { int w = calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); Console.WriteLine("{0}\t{1}", date.ToString("dd.MM.yyyy"), w); date = date.AddDays(1); }