XSLT order in months AND years - xslt

I have a problem. I have an XML tree which looks similar to this:
<wd:meta>
<wd:creation time="[TIMESTAMP]" />
<wd:title><![CDATA[Nice title]]></wd:title>
</wd:meta>
And there are many more siblings with the same Structure.
This tree goes into the XSLTProcessor and gets a nice Stylesheet.
Now i want to take this apart into months (In my Stylesheet). So that there is something like that:
Everything that happed in August
Nice title 1
Nice title 2
Everything that happend in September
Nice title 3
Nice title 4
How can i do something like this? I made a little bit of research but i wasn't very successful.
The only thing i found what would be maybe useful was that: following-sibling
Can anyone help me? I really appreciate your help.
Thanks.
edit://
I now used the Muenchian method adopted from http://www.jenitennison.com/xslt/grouping/muenchian.html but i only can order it by month, NOT by year. I tried the Answer of the possible duplicate and tried to understand it, but it's not that easy. Has anyone a easier solution?

In a first step i would iterate your content and generate a monthname for your timestamps. Then you can sort it by the month name. If you have xslt 2.0 you can use group-by to group them by month. If not, you can acturlly iterate your content and check if there is a following-sibling with the current month name. If so, go on with the same month name as the month of the current element. If not, start a new month.

Related

Django query to find value of objects from previous period (if exists)

I have a simple django project and I am trying to keep track of ranks for certain objects to see how they change over time. For example, what was the rank of US GDP (compared to other countries) over last 3 years. Below is the postgres db structure I am working with:
Below is what I am trying to achieve:
What I am finding challenging is that the previous period value may or may not exist and it's possible that even the entity may or may not be in the pervious period. Period can be year, quarter or months but for a specific record it can be either of one and stays consistently same for all the years for that record.
Can someone guide me in the right direction to write a query to achieve those tables? I am trying to avoid writing heavy forloop queries because there may be 100s of entities and many years of data.
So far I have only been able to achieve the below output:
I am just trying to figure out how to use annotate to fetch previous period values and ranks but I am pretty much stuck.

Exclude date via .exclude

I have been looking everywhere for documentation on excluding time and before and after. Ie My app for school is for appointments. They want me to make sure no one can sign up earlier than the current day. If someone could give me a format I have it so i can strip it down to just the day. But not only an solution to the problem but a link to some great detailed documentation as I need date and time for a lot on this project would be good.
'other' : Item.objects.exclude(time |date:"M d, Y"),
that is the current code it does not work. I get invalid syntax. If I take out the () of it my page loads so the () is the issue. Any help would be greatly appropriated.
Maybe try filtering a date range instead of excluding before and after
Item.objects.filter(date__range=["2017-01-01", "2017-01-31"])
To exclude before and after something like this should work with __lt for less than and __gt for greater than:
Item.objects.exclude(date__lt=datetime.date(2017, 1, 1)).exclude(date__gt=datetime.date(2017, 1, 31))

Google Spreadsheets - IF with more that three arguments

I'm currently working an a very simple project management template.
The Idea is that after entering a start and end-date columns will show up as a very simplistic gantt chart (conditional formating).
Everything works fine, until "year" comes into consideration. Since it is a several years lasting project and we work with calenderweeks it is essential that the work package is only visualized in its specific year.
So I came up with the following (rough'n'dirty) formular (example from cell K3):
=and(if(K$2>=$F3;1;0);if(K$2<=$H3;1;0);if(or(right($E3;4)=K$1;1);(right(G3;4)=K1;1;0)))
This is the document: https://docs.google.com/spreadsheets/d/15F1uBnoHMuJqc_w0X04U5-ZCQ_6mgO_HJqvN5U28cog/edit?usp=sharing
Problem: GoogleSpreadsheets only alows three arguments with IF. But I do not know how to structure it otherwise...
Thankful for any suggestion!
Cheers,
Matt
This might be what you are looking for, ties the start week/ end week and year together for comparison.
=IF(AND(
(K$1&TEXT(K$2;"00")) >=(RIGHT($E$3;4)&TEXT($F$3;"00"));
(K$1&TEXT(K$2;"00")) <=(RIGHT($G$3;4)&TEXT($H$3;"00")))
;1;0)

COUNTIF ? I need to count dates, but only once

I have a sheet that has become complex, it has a lot of filters and I need to populate a table with data. I am counting how many times a month we run a product. If we run it once a day, or more, I want to only count that as one.
Date Product Grizzly
1/1 2.5 open
1/1 1.5 closed
1/1 2.5 closed
1/1 2.5 open
Something a little more elaborate than this, but what I need is to count this as one day of 2.5 grizzly closed, instead of two.
Any help? I feel like there is something simple I am missing but cant put my thumb on it and I have spent well over 15 hours working on this.
As found on the following link:
Link to Answer
Try using the DCOUNTA function within Excel.
Although I'm also sure that you could use a pivot chart to provide the same outcome.
EDIT:
I am assuming you are starting with data like the following:
I then created the following table which you can extend to comply with you total data value. For example, you can add extra dates and products.:
The table is populated using a COUNTIFS function.
=COUNTIFS("DateRange",DateCriteria, "ProductRange", ProductCriteria, "GrizzlyRange", GrizzlyCriteria)
So in my table the formula looks like this but the cell references will obviously changes according to your spreadsheet (I used absolute references to make it easier to use the fill handle to copy the formula down:
=COUNTIFS($A:$A,$E4,$B:$B,$F$3,$C:$C,$F$2)
I next nestled this formula in to an IF statement and applied a conditional formatting to end up with the following:
So the formula for each of the cells is now:
=IF("OriginalFormula),"Yes","No")
Example of my 01/01/2015, 1.5 open value:
=IF(COUNTIFS($A:$A,$E4,$B:$B,$F$3,$C:$C,$F$2),"Yes","No")
BUT - You can change the "Yes" and "No" to "1" and "0" if you want to stick with numerical values.

Library to discover dates from text?

I need to pull a date out of a string. Since not everyone uses the official ISO format when printing their dates, it is impractical to write a date parser for every possible date format that could be used, and I need to handle as many date formats as possible - I don't control the data and can't expect it to come in a specific format.
This seems like a problem that has probably already been solved ages ago, but my Google-fu is too weak to find the solution. :(
Does there already exist a C++ library that, given a string, will return the month, day, year, hour, minute, second, etc that is referenced in that string, if any?
Pseudocode:
string s1 = "There is an expected meteor shower this Thursday,"
"August 15th 2013 at 4:39 AM.";
string s2 = "20130815T04:39:00";
date d1 = magicConverter(s1);
date d2 = magicConverter(s2);
assert(d1 == d2);
You might use the code from here, but you need to configure a mask, that tells the code which time format is used. If you write a class routine, that takes a mask and a string and gets you out the time and is able to print in any format you like, you should be well prepared. You have to look in more detail, if it also supports Daynames and Monthnames. I got it to work in python with a module providing a function that seems pretty much the same.
For more detail:
Please look at the example 2013-08-03 again. Nobody and as follows no computer is able to tell you if this date belongs to August or April, except of having a mask telling JJJJ-MM-DD or JJJJ-DD-MM. Also this library may tell you only standard masked times. So it might lead you to August in this case. But as you said it can be any date declaration, thus it does not need to follow standards, thus it can also mean March. An other possibility is to tell you about the date from the context (e.g. a table with a column of all te same time formats by looking for the increase (which would also fail if you just look at one day per month for just one year).
Another example... if I ask you 2013-05-04... to which month does it belong? You might tell me... April. I would reply "no, to the 4th of May" and vice versa for May and 5th of April. If you tell me how to solve this puzzle with two possible solutions I would understand your downvote... please think before downvoting someone trying to help you.