Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


FIRST date after Quarter

FIRST date after Quarter

FIRST date after Quarter

consider this current Quarter 2015 (Jule 2015, august 2015, september 2015)

and myvardate="05/10/2015" (myvardate as Date)

with a code in vb6 is possible to check if myvardate is the first date after the last month in Quarter?

RE: FIRST date after Quarter

Anything is possible. You just have to define the rules.

When does your quarter start? Is it on the 1st or the first Sunday or the first Monday of every third month.

RE: FIRST date after Quarter

There are lots of intrinsic functions supporting date/time operations. These are covered very well in That Fine Manual.

Surely this will help provide a clue?


Option Explicit

Private Function Quarter(ByVal Value As Date) As Long
    'Combine year and quarter to permit easy comparisons
    '(though not arithmetic):
    Quarter = DatePart("yyyy", Value) * 10 + DatePart("q", Value)
End Function

Private Function NextQuarterBegins(ByVal Value As Date) As Date
    NextQuarterBegins = DateSerial(Year(Value), _
                                   (((DatePart("m", Value) - 1) \ 3) + 1) * 3 + 1, _
End Function

Private Sub Form_Load()
    Dim TestDate As Date
    TestDate = "May-10-2015"
    Text1.Text = "TestDate is " & Format$(TestDate, "mmm-dd-yyyy") & vbNewLine _
               & "Quarter(TestDate) is " & CStr(Quarter(TestDate)) & vbNewLine _
               & "Quarter(""Jul-01-2015"") is " _
               & CStr(Quarter("Jul-01-2015")) & vbNewLine _
               & "NextQuarterBegins(TestDate) is " _
               & Format$(NextQuarterBegins(TestDate), "mmm-dd-yyyy")
End Sub 



TestDate is May-10-2015
Quarter(TestDate) is 20152
Quarter("Jul-01-2015") is 20153
NextQuarterBegins(TestDate) is Jul-01-2015 

RE: FIRST date after Quarter

sorry me Dilettante but my date really is 05/10/2015 (five ottober 2015) and not 10/05/2015...why you use that?

in this case 05/10/2015 is really the first date based the last month in last Quarter (settember 2015 in my case)

and i think your code not help me, for now.

RE: FIRST date after Quarter

Like xwb said: "You just have to define the rules."

Fill the blanks:

               Start Date      End Date
1st Quarter    __________    ___________
2nd Quarter    __________    ___________
3rd Quarter    __________    ___________
4th Quarter    __________    ___________ 

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: FIRST date after Quarter

>why you use that?

Dilettante lives in a region with a different date format to you.

RE: FIRST date after Quarter

Aren't DatePart and DateSerial Locale aware/independent anyway?

(genuine question; I haven't touched VB for a very long time)

Take Care

I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.

RE: FIRST date after Quarter

Sure, but the posters are not smile

2009luca: myvardate="05/10/2015"

interpreted as

Dilettante: TestDate = "May-10-2015"

RE: FIRST date after Quarter

Indeed, but one of those examples is unambiguous and VB will cast/coerce to a valid and expected date variable. The other can have unexpected results...

Take Care

I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.

RE: FIRST date after Quarter

If people are getting this lost over regional date formats... they probably don't qualify for membership at this site anyway. These are long-standing and long understood issues in VB and this site is only meant for professional users.

And no, plinking around with code on the job does not make you "professional" no matter how shiny your suit is or how natty your tie is.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close