Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

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

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

ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to do it before April 8 (in other words not "on or before" April 8) then change the "09" to "08".
Avatar of al4629740

ASKER

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

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?
Ah.  It was a formatting issue.

Thanks
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