Solved

date statement in vb6 by month and day only.  Not year

Posted on 2014-01-30
6
267 Views
Last Modified: 2014-01-30
Every year, I need to process certain code before April 8 and after January1.  How can I do that using the code below?

SelectMonth = Format(currentServerTime, "mmmm")
            SelectDay = Format(currentServerTime, "dd")
            
            
            If (SelectMonth < "April" And SelectMonth < 9) And (SelectMonth < "January" And SelectMonth > 1) Then
            'add code here
            End If

Open in new window

0
Comment
Question by:al4629740
  • 3
  • 3
6 Comments
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39821662
If (SelectMonth < "April" And SelectDay < "09") And (SelectMonth < "January" And SelectDay> "01") Then
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39821670
If you want to do it before April 8 (in other words not "on or before" April 8) then change the "09" to "08".
0
 

Author Comment

by:al4629740
ID: 39821681
This isn't working

esql = "select GetDate()"
                rec.Open (esql), conn, adOpenStatic, adLockReadOnly
                currentServerTime = rec.Fields(0)
                rec.Close
                    
            SelectMonth = Format(currentServerTime, "mmmm")
            SelectDay = Format(currentServerTime, "dd")
            
            
            If (SelectMonth < "April" And SelectDay < "09") And (SelectMonth > "January" And SelectDay > "01") Then
            Combo1.AddItem "January,February,March"
            End If

Open in new window

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:al4629740
ID: 39821759
This doesn't seem to work either

If currentServerTime < "04/09/14" And currentServerTime > "01/01/14" Then
            Combo1.AddItem "January,February,March"
            End If

What am I doing wrong?
0
 

Author Comment

by:al4629740
ID: 39821776
Ah.  It was a formatting issue.

Thanks
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39821806
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now