?
Solved

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

Posted on 2014-01-30
6
Medium Priority
?
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 48

Accepted Solution

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

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 48

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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