I am working in Excel 2007. My preference would be to do this without VBA. I am trying to count backwards a number of months starting from a given date. For example:
Start Date: July, 2010
Countdown: 12 months
Should result in:
Jun 2010
May 2010
Apr 2010
Mar 2010
Feb 2010
Jan 2010
Dec 2009
Nov 2009
Oct 2009
Sep 2009
Aug 2009
Jul 2009
So the seed month is month 0 and the countdown period can vary. I would like the month/year combination for display purposes but I also need the calculated value (ie, seed month is 0, next previous month is -1, etc) for calculations.
Any advice/help would be most appreciated!
It's relatively simple. For example, in cell A1, put "July 2010". In B1, put =DATE(YEAR(A1),MONTH(A1)-1,DAY(A1)) and in C1 put either =DATE(YEAR(A1),MONTH(A1)-2,DAY(A1)) or =DATE(YEAR(B1),MONTH(B1)-1,DAY(B1)) and so on.
If you're looking for a for/each type of statement with the number of months in the countdown, you'll need to go to VBA. Otherwise, you can prepopulate a range of cells with code like the above (You can start it with an if statement if the countdown cell has nothing, to display nothing).
Related
I have been looking high and low and so far have seen no options via the code or anything else that seems to even come close to what i am asking. My request is simple enough. Typically when we want to display in a month grid view the month of September 2019 we expect the start of this month to be 9/1/2019 and the end to be 9/30/2019 with anything before or after to be considered other month.
However, I need for my calendar to have a different date range for the month of September 2019. This is so that it aligns with how we manage months. With the exception of the month of October all other months of the year are modified for different date range.
January = 01/01 to 01/30
February = 01/31 to 03/01
March = 03/02 to 03/31
April = 04/01 to 05/01
May = 05/02 to 06/01
June = 06/02 to 07/01
July = 07/02 to 07/31
August = 08/01 to 08/30
September = 08/31 to 09/30
October = 10/01 to 10/31
November = 11/01 to 12/01
December = 12/02 to 12/31
In many cases I do not need to make many adjustments (just some add/remove "fc-other-month" class, as the previous months ending dates are also visible (if using the 6 week enabled flag, which is also set by default), however, in September 2019, 09/01 is on a Sunday of the first week meaning that the previous week that would include 8/31 is not rendered.
I can explore a "brute force" type method of checking for this condition and then prepending another row on top of week 1 with the additional dates needed but I have to believe that there is a simple method where i can simply state the months start and end date range.
I need to create a Chart Report where I need to display the data rolling 12 months and more than 12 months.For example, my Cognos Report is displaying data from Dec2018 to Dec 2019 but post 2019 it should reflect date from Dec 2019 to Dec 2020.
Also, there is a summary sheet below which has values against KPI's and applying some calculations on those value, I need to show in Report.Like, there is a value in KPI (98765) for Dec 2018 and I need to reflect (98765/1000) above.A sample Report is provided below.
Try this Filter
[Date] >= _add_years(_add_days(current_date, -1), -1)
Then for the measures
Definition for the data item rolling 12
IF([Date] <= current_date)Then([Measure])Else(0)
Definition for the data item post
IF([Date] < current_date)Then([Measure])Else(0)
I did already search in past answers for nearly two days but found no solution. I have a table with a column 'projects', column 'country' and a column 'timeframe'. I want to count the number of projects, grouped by country, which did start before 2017. The data looks like
ProjectID CountryID Time
5 3 Enero/2011 - Diciembre/2020
6 3 June 2017 - December 2020
7 3 June 2017 - December 2030
8 5 NULL
9 11 July 2017 - December 2020
10 11 7/2017 - 12/2020
11 5 2017 June - 2020 January
The problem is the format of the Time, but as it is a large dataset I cannot change the format manually. I tried my best to do something like
SELECT *, COUNT (*)
WHERE (Time LIKE '%XX% - %' AND XX < 2018);
but I cannot find the right way to include the parameter XX in the query. Is there any way to get this done without re-writing all data manually?
Thanks a lot!
Thanks Tripehound - substrings did help! For the Start year
SELECT ID, substr(TimeFrame, instr((TimeFrame),'20'),4) AS ProjectStart
, Count(*) AS NumberProjects
FROM Timeframe
WHERE ProjectStart>"2017";
did do the job; for the end year it was
SELECT substr(TimeFrame, instr(TimeFrame,'-')-1+instr(substr(TimeFrame, instr(TimeFrame,'-')), '20'), 4) AS ProjectEnd,
Count(*) AS ProjectsNumber
FROM Timeframe
WHERE ProjectEnd<"2030";
Done!
I'm trying to use the date command to get the previous month. When I run it on the 31 of may, it returns may 1, I was expecting something in april. Is there better way to do this ?
> date --version
date (GNU sh-utils) 2.0
Written by David MacKenzie.
Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> date
Fri May 31 13:29:08 EDT 2013
> date --date='last month'
Wed May 1 13:29:15 EDT 2013
per comment from #fvu I tried this :
> date --date='first day last month'
Thu May 2 14:00:43 EDT 2013
> date --date='first day next month'
Tue Jul 2 14:00:52 EDT 2013
which didn't quite work. this did though :
>date --date='last day last month'
Tue Apr 30 14:06:28 EDT 2013
guess I need the definition of month
"last month" is meant to be 30 days ago, not the previous month, I believe.
date --date="$(date +%Y-%m-15) -1 month"
is the info example given to detect the previous month because -1 month is the same as -30 days
$datetime = new DateTime('0000-00-00 00:00:00');
$date_string = $datetime->format('Y-m-d H:i:s');//-0001-11-30 00:00:00
date gets turned from 0000-00-00 00:00:00 to -0001-11-30 00:00:00
this is obviously wrong, why does this happen, how to fix it?
Should at least return false.
info:
PHP Version 5.2.13-0.dotdeb.1
Linux 2.6.26-2-openvz-amd64 #1 SMP Thu Nov 25 05:14:47 UTC 2010 x86_64
It's sort of correct by definition:
the zero-th day as opposed to the first yields a (hypothetical) minus one day
the zero-th month as opposed to the first yields a (hypothetical) minus one month
Take the (hypothetical) 1st of Jan in the year 0, subtract a month -> 1st of Dec in the year -1.
Subtract a day -> 30th of Nov in the year -1
Alternatively, they could have chosen to fix up the day first, then it'd go like:
1 Jan minus 1d -> 31st of Dec -0001, minus 1mo -> 30th of Nov -0001
The formatter obviously does the bound check to only produce valid dates. (For some definition of ``valid'')