Solved

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

Posted on 2014-01-30
6
270 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 46

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 46

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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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 46

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

773 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