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
Solved

Execute code on specific day

Posted on 2013-06-18
4
257 Views
Last Modified: 2013-06-19
The code below executes the 9th of each month.  I would like to change the following vb6 code to execute when it is only July 9,2013.

currentservertime already contains the current date.  

How do I do that?

If Day(currentServerTime) < 9 Then
                    'Add code here
            End If

Open in new window

0
Comment
Question by:al4629740
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Faustulus earned 500 total points
ID: 39258237
How about this?
If Date = DateSerial(2013,7,9) Then
    ' add your code here
End If

Open in new window

You can expand on the idea like this:-
If Now > (DateSerial(2013,7,9) + TimeSerial(12,0,0)) Then
    ' add your code here
End If

Open in new window

This would run any time after 12 pm on July 9. Your code could include a line to abort if the time window you want to allow is exceeded.
Basically, if you wish a program to run on July 9, 2013 you would need to set a timer which would wake up the computer and run the program when the time has arrived. This is what they use for automatic backups. The above kind of code would need to be called by the user or, perhaps a startup procedure, and then refuse to run at any other time. But it could be run multiple times within the prescribed time frame unless your code includes provision to allow it to run only once.
0
 

Author Comment

by:al4629740
ID: 39258379
Can I do
July 9, 2013. 8:00pm
0
 

Author Comment

by:al4629740
ID: 39258430
This didn't work.  Do I have the format wrong

If Date = DateSerial(2013,7,9) Then
    ' add your code here
End If
0
 
LVL 14

Expert Comment

by:Faustulus
ID: 39258554
TimeSerial(20,0,0) would define 8 pm. The parameters are Hour, Minute, Second - all counting from 00:00 h military time.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 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…

829 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