Formatting a date retrieved from Wikidata - date

So let's say I have an Infobox template in Wikipedia that retrieves a company foundation date from Wikidata. It contains the following code:
|label7 = Year founded
|text7 = {{wikidata|p571|{{{founded|}}}}}
My problem is that what's retrieved is formatted as 31 January 2010 and it looks weird next to "Year founded' since it is not a year but the whole date. Of course I could rename the label from "Year founded" to "Date founded" and voila, problem solved, right? But I do want to just get the year from Wikidata, not the whole date.
What would be the code for this? I imagine something like {{wikidata|p571[year]|{{{founded|}}}}} or {{wikidata|p571[0]|{{{founded|}}}}} or {{wikidata|p571[YYYY]|{{{founded|}}}}}.
Thanks in advance!

This doesn't sound like a programming question, but it looks like you can request a specific date format as the third parameter to wikidata
https://en.wikipedia.org/wiki/Module:Wikidata#Testing_getValue.2C_getRawValue_and_getDateValue
{{#invoke:Wikidata|getDateValue|P569|FETCH_WIKIDATA|y}}

I highly recomend you to filter the year from date using RegularExpression instead of trying to get only the year.

Related

how to make a day from date in LibreOffice?

I want to convert date into a Day
I am using LibreOffice
I used some of its syntax weekday and text but it returns nothing
WEEKDAY("30-04-2019"; 1) is there any way to do that?
in google sheet i used =TEXT(C7758,"dddd") but it didn't work
how can I do that?
thanks in advance
Try the combination of functions WEEKDAY and DATE:
=WEEKDAY(DATE(2019;4;30))
The specific example will return 3 which is Tuesday (see all days and other options at https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_WEEKDAY_function)
Hope that helps.

Format date and add month to it

I'm currently working with embarcadero c++, this is the first time I'm working with it so it's completely new to me.
What I'm trying to achieve is to get the current date, make sure the date has the "dd/MM/yyyy" format. When I'm sure this is the case I want to add a month to the current date.
So let's say the current date is 08/18/2016 this has to be changed to 18/08/2016 and then the end result should be 18/09/2016.
I've found that there is a method for this in embarcardero however I'm not sure how to use this.
currently I've only been able to get the current date like this.
TDateTime currentDate = Date();
I hope someone will be able to help me out here.
I figured it out.
After I've searched some more I found the way to use the IncMonth method on this page.
The example given my problem is as follows:
void __fastcall TForm1::edtMonthsExit(TObject *Sender)
{
TDateTime StartDate = edtStartDate->Text;
int Months = edtMonths->Text.ToInt();
TDateTime NextPeriod = IncMonth(StartDate, Months);
edtNextPeriod->Text = NextPeriod;
}
After looking at I changed my code accordingly to this
TDateTime CurrentDate = Date();
TDateTime EndDate = IncMonth(CurrentDate, 1);
A date object doesn't have a format like "dd/MM/yyyy". A date object is internally simply represented as a number (or possibly some other form of representation that really isn't your problem or responsibility).
So you don't have to check if it's in this format because no date objects will ever be in this format, they simply don't have a format.
You will have to do additions/subtractions on the Date object that the language or library gives you, THEN (optionally) you can format it to a human-readable string so it looks like 18/08/2016 or 18th of August 2016 or whatever other readable format that you choose.
It might be that the TRANSFER of a date between 2 systems is in a similar format, but then formatting the date like that is entirely up to you.
As for how to do that, the link you posted seems like a possible way (or alternatively http://docwiki.embarcadero.com/Libraries/Berlin/en/System.SysUtils.IncMonth), I'm afraid I can't give you an example as I'm not familiar with the tool/language involved, I'm just speaking generically about Date manipulations and they should ALWAYS be on the raw object.

I need the complete list of date format in meteor autoform

I am trying to bring up a date format of "Monday, February 2,2015" in meteor autoform, from this code
moment.utc("2015-02-02").format("LL")
I would like to have a list like in php.date function shows the full date format.
I believe each one of us will find few and post here so that we get the complete list. I googled and I never got the list.
I'm not sure I fully understand your question but this might help.
http://momentjs.com/

How can I add several months to a date coming from a date form field?

With DateJS, you'd add e.g. six months to the current date like this:
Date.today().addMonths(6);
However, I need to add 24 months not to today's date, but to a date which a user has typed into a date field. So the today() should in principle be replaced by something like this.getField('begin_date').value.
The result shall be written into another data form field.
I tried hard, but couldn't make it. Can anyone help me out?
Providing the input value is a textual representation of a date, you need to convert it into a Date object at the first place. Then you can work with it as you want.
DateJS has a pretty smart parse() function which does exactly that, so you'd achieve it like this:
Date.parse(this.getField('begin_date').value).addMonths(24)
When a specific date format is needed, like DD.MM.YYYY commonly used in Europe, you can use parseExact() and specify the format. Like this:
Date.parseExact(dateToParse, 'dd.MM.yyyy') // leading zeroes required; parses 01.04.2014 but not 1.4.2014
Date.parseExact(dateToParse, 'd.M.yyyy') // leading zeroes not required; parses both 01.04.2014 and 1.4.2014
Here is a solution that I found for my problem, using DateJS as well:
start = this.getField('begin_date').value;
var d1 = util.scand("dd.mm.yyyy", start);
var myDate = new Date(d1);
result = myDate.addMonths(24);
This works pretty fine, also spanning leap years, except for the 28th of February, 2014/2018/2022 ... ; the result then will be the 28th of February, 2016/2020/2024 ... and not the 29th of February 2016/2020/2024... In these cases it's up to the user to accept the 28th or to manually change the date to the 29th.

Localized Date (LongDatePattern) Remove the year

I have this code to retrieve the Localized Date:
DateTime.Now.ToString(DateTimeFormatInfo.CurrentInfo.LongDatePattern);
The thing is that it returns the year also. I don't want the year.
So I thought I could remove the year pattern from the LongDatePattern. But there are commas in some countries and it would look bad if I removed the 2013 year.
Can someone help me to be able to do it?
Windows.Globalization.DateTimeFormatting.DateTimeFormatter will allow you to supply a template that specifies exactly which components you want included in the formatted result ("month day dayofweek") for example.