admit have myvardate=05/10/2015
i need to check if is the first helpful date after the last month in the current quarter. in my case 05/10/2015 is thrue.
Possible?
in my case is settember the last month in current quarter.
or for example 08/01/2016 is the first helpful date after the last month in quarter ottober, november dicember
first date after the last month in quarter
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: first date after the last month in quarter
Narest...HansV wrote:What is a "helpful" date?
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: first date after the last month in quarter
I'm sorry, I don't understand what you want. Can you try to explain it more clearly?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: first date after the last month in quarter
In effett i need to start to the end of each quarter my macro code.HansV wrote:I'm sorry, I don't understand what you want. Can you try to explain it more clearly?
That is all
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: first date after the last month in quarter
But why would the result be 08/01/2016 is the quarter is October/November/December?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: first date after the last month in quarter
dont consider this...HansV wrote:But why would the result be 08/01/2016 is the quarter is October/November/December?
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: first date after the last month in quarter
Does this do what you want?
Dim newDate As Date
newDate = DateSerial(Year(myvardate), 3 * ((Month(myvardate) - 1) \ 3) + 4, 1)
Dim newDate As Date
newDate = DateSerial(Year(myvardate), 3 * ((Month(myvardate) - 1) \ 3) + 4, 1)
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: first date after the last month in quarter
HansV wrote:Does this do what you want?
Dim newDate As Date
newDate = DateSerial(Year(myvardate), 3 * ((Month(myvardate) - 1) \ 3) + 4, 1)
hummmm....
I propose again my condition in pseudo code:
is 08/10/2015 the first date after the last day in elapsed Quarter?
last day in elapsed Quarter is 30/09/2015, 08/10/2015 is the first date near...
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: first date after the last month in quarter
Sorry, I don't understand that. Why is 08/10/2015 the first date after 30/09/2015?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: first date after the last month in quarter
I run a code each day and i need the check function each day.HansV wrote:Sorry, I don't understand that. Why is 08/10/2015 the first date after 30/09/2015?
08 october is day now
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: first date after the last month in quarter
The current date is always later than the end of the previous quarter, by definition.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: first date after the last month in quarter
HansV wrote:The current date is always later than the end of the previous quarter, by definition.
study on Quarter
this function return steep of Quarter, but i see return in a last date one day -1!!!!
Dim anno As Integer, I As Integer
anno = 2015
For I = 1 To 4
Debug.Print I & "Q - DAL: " & Format(DateSerial(anno, (I - 1) * 3 + 1, 1), "dd/mm/yyyy") _
& " AL: " & Format(DateSerial(anno, I * 3 + 1, -1), "dd/mm/yyyy")
Next
in debug.print, have:
1Q - Da: 01/01/2015 A: 30/03/2015<31/03/2015
2Q - Da: 01/04/2015 A: 29/06/2015<30/06/2015
3Q - Da: 01/07/2015 A: 29/09/2015<30/09/2015
4Q - Da: 01/10/2015 A: 30/12/2015<31/12/2015
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: first date after the last month in quarter
The solution is very simple: use 0 instead of -1:
Debug.Print I & "Q - DAL: " & Format(DateSerial(anno, (I - 1) * 3 + 1, 1), "dd/mm/yyyy") _
& " AL: " & Format(DateSerial(anno, I * 3 + 1, 0), "dd/mm/yyyy")
Debug.Print I & "Q - DAL: " & Format(DateSerial(anno, (I - 1) * 3 + 1, 1), "dd/mm/yyyy") _
& " AL: " & Format(DateSerial(anno, I * 3 + 1, 0), "dd/mm/yyyy")
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: first date after the last month in quarter
Cross-posted at: http://www.tek-tips.com/viewthread.cfm?qid=1755999" onclick="window.open(this.href);return false;
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184" onclick="window.open(this.href);return false;
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184" onclick="window.open(this.href);return false;
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]