Google Sheets function "=Year(2001)" returns 1905 - date

When I enter =Year() with any year as argument (e.g. 2010), I always get 1905 as a result
At first i thought that my cell reference is broken, but it also happens when I enter the year directly into the formula.
The same thing happens when I enter =TEXT(2010;"YYYY") --> 1905 ???
What am I doing wrong?

You need to write
=YEAR(DATE(2010,1,1))
What 2005 is equivalent to
=INT(DATE(1905,3,19))
YEAR takes an integer value, DATE will convert for you the year, month and day to an integer.

Related

Cakephp 3 i18nFormat string for the number of weeks in a specified date

How to get number of week for specific date in cakephp 3?
$this->mydate->i18nFormat('yyyy-MM-dd') will display year-month-date.
But what about string format for week number?
Thanks.
Have a closer look at the docs for Cake\I18n\Time::i18nFormat(), it tells you what you can pass as the format, and where to find a list of the accepted formatting patterns:
[...] You can either pass IntlDateFormatter constants as the first
argument of this function, or pass a full ICU date formatting string
as specified in the following resource:
https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax.
Cookbook > Date & Time > Formatting > Cake\I18n\Time::i18nFormat()
So long story short, the pattern letter for the week of the year is w, or ww if you want a leading zero, and for the week of the month it's W or WW.

unexpected result converting date using datestr

Can anyone tell me why if I type in MATLAB
datestr('17-03-2016','dd-mmmm-yyyy')
I get
06-September-0022
From the datestr docs
DateString = datestr(___,formatOut) specifies the format of the output text using formatOut. You can use formatOut with any of the input arguments in the above syntaxes.
So in your example the 'dd-mmmm-yyyy' is specifying the output format, not the input format.
Also
DateString = datestr(DateStringIn) converts DateStringIn to text in the format, day-month-year hour:minute:second. All dates and times represented in DateStringIn must have the same format.
where
'dd-mm-yyyy' is not in the list of allowed DateStringIn formats AND the documentation explicitly recommends using datenum to ensure correct behaviour. (Note: I underlined the wrong must in the sentence, it's the second must I wanted to emphasise)
So Sandar_Usama's answer of
datestr(datenum('17-03-2016','dd-mmmm-yyyy'))
is the officially correct method straight out of the docs.
Bottom line, always read the documentation.
Use this instead: datestr(datenum('17-03-2016','dd-mmmm-yyyy'))
To address the last unanswered point in this question, why does datenum behave like this?
>> datestr(datenum('17-03-2016'))
ans =
06-Sep-0022
Without explicitly telling datestr and datenum how it should treat the input, it will try to match against the expected formats. Since none of the documented formats match (see #dan's answer), it fails.
Although what it does next is undocumented, at least up to whatever version of Matlab we are running, it falls into a "last resource" attempt to give you a date number.
Matlab will try to parse different month names from your input, remove non-numeric characters, and then timedate elements from the string. In your case, they are 17, 03, and 2016. The first is expected to be either month or year. Since there's no 17th month, it is treated as year. Then 03 is the month, and 2016 is the day.
Now, March 2016th, 17 is not a valid date, but Matlab will give it a slack and read as 1985 days past March 31st, 17. And that gives us September 6th, 22.
Because Matlab's timestamp is a floating number for the number of days since its epoch, you can trigger that answer, using valid dates, like so:
>> datestr(datenum('0017-03-31') + 1985)
ans =
06-Sep-0022

How to get month name in jasper studio expression editor

I am using this command to get the date in jasperstudio expression editor
new SimpleDateFormat("dd.MM.yyyy").format($F{day_date})
This will return date value example like 01.01.2010 however i want the month to have a name like 01.Jan.2010 -- please advise
In your specified format "dd.MM.yyyy", MM gives you the month as a number.
You can use "dd.MMM.yyyy" to get an abbreviated month name.
Similarly, if you need the full month name you can use "dd.MMMM.yyyy"

Editing the year in date field in EXTJS 4.0 is defaulting the year to 2020

I have a date field in a form
xtype: 'datefield',
id: 'dateId',
maskRe: /[0-9\/]/,
format : 'm/d/Y',
for ex - if the date populated in that field is 07/30/2014. now i want to manually edit the date, if i give two backspaces, which means 07/30/20. and then click some where in the form, the year is getting defaulted to 07/30/2020. how to stop this getting defaulted to that 2020 year.
I answered this in my comment, but I will try to expand on that comment as much as possible, and make it as clear as possible. Here is the original comment:
"07/30/20 is equivalent to 07/30/2020. This is expected and normal behavior. When a year is only two digits, it is always the last two digits, so 20 == 2020, 00 == 2000, 14 == 2014, etc."
So, let me step you through an example.
You type 08/08/2014 into the datefield.
Hit backspace twice, removing the 1 and the 4.
Now you have 08/08/20.
When writing dates, the year can be written as 2 digits or 4. If written as two, the last two digits are used. So, the year 20 is the same as the year 2020.
The datefield has logic to handle 2 digit dates, so it knows that 08/08/20 is actually 08/08/2020.
That is why when you have 08/08/20 in a datefield, it interprets it as 08/08/2020.

Bug in Zend_Date (back in time)

I have a very strange problem, Zend_Date is converting my timestamp to a year earlier.
In my action:
// Timestamp
$intTime = 1293922800;
// Zend_Date object
$objZendDate = new Zend_Date($intTime);
// Get date
echo date('Y-m-d',$intTime).'<br>';
echo $objZendDate->get('YYYY-MM-dd');
This outputs:
2011-01-02
2010-01-02
Can anyone tell me what i'm doing wrong?
From the ZF issue tracker it seems this is a known issue:
Recently a lot of ZF users are filing a bug that Zend_Date returns the wrong year, 2009 instead of 2008. This is however expected behaviour, and NOT A BUG!
From the FAQ:
When using own formats in your code you could come to a situation where you get for example 29.12.2009, but you expected to get 29.12.2008.
There is one year difference: 2009 instead of 2008. You should use the lower cased year constant. See this example:
$date->toString('dd.MM.yyyy');
instead of
$date->toString('dd.MM.YYYY');
From the manual
Note that the default ISO format differs from PHP's format which can be irritating if you have not used in previous. Especially the format specifiers for Year and Minute are often not used in the intended way.
For year there are two specifiers available which are often mistaken. The Y specifier for the ISO year and the y specifier for the real year. The difference is small but significant. Y calculates the ISO year, which is often used for calendar formats. See for example the 31. December 2007. The real year is 2007, but it is the first day of the first week in the week 1 of the year 2008. So, if you are using 'dd.MM.yyyy' you will get '31.December.2007' but if you use 'dd.MM.YYYY' you will get '31.December.2008'. As you see this is no bug but a expected behaviour depending on the used specifiers.
For minute the difference is not so big. ISO uses the specifier m for the minute, unlike PHP which uses i. So if you are getting no minute in your format check if you have used the right specifier.
To add to zwip's answer, what happens behind the scenes is that your date format YYYY-MM-dd is actually translated into o\-m\-d, which is then passed to PHP's date() function internally with the timestamp you provided.
Like mentioned in the other answer, and in the documentation for the o format on the date format page, the calculation of the year based on the ISO week can sometimes result in the year being one different to the value that you expect.