|
-
Aug 21st, 2008, 08:11 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Adding to a date?
I'm trying to create a timescale, and need to add 5 minutes to a date every 10 seconds, i have a timer setup on the right interval, but i can't figure out how to add 10 minutes to a DATE variable.
Doing MyTime = MyTime + 10 just adds 10 days, i tried using 0.1 and it went wacko and displayed a seemingly random time. Any help?
-
Aug 21st, 2008, 08:24 AM
#2
Hyperactive Member
Re: Adding to a date?
VB has a built in function called DateAdd for this kind of thing,
make a new project and paste this into an event of your choice:
Code:
Dim aDate As Date
aDate = Now()
MsgBox aDate
MsgBox DateAdd("n", 5, aDate) 'Adds 5 minutes to the aDate variable
Heres a list of the possible values for Interval that i copied from msdn
String Unit of time interval to add
d Day; truncated to integral value
y Day; truncated to integral value
h Hour; truncated to integral value
n Minute; truncated to integral value
m Month; truncated to integral value
q Quarter; truncated to integral value
s Second; truncated to integral value
w Day; truncated to integral value
ww Week; truncated to integral value
yyyy Year; truncated to integral value
Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White
-
Aug 21st, 2008, 08:53 AM
#3
Thread Starter
Hyperactive Member
Re: Adding to a date?
Perfect, thanks much Arachnid.
-
Aug 21st, 2008, 07:35 PM
#4
Re: [RESOLVED] Adding to a date?
 Originally Posted by Teseng
I'm trying to create a timescale, and need to add 5 minutes to a date every 10 seconds, i have a timer setup on the right interval, but i can't figure out how to add 10 minutes to a DATE variable.
Doing MyTime = MyTime + 10 just adds 10 days, i tried using 0.1 and it went wacko and displayed a seemingly random time. Any help?
0.1 is interpreted as 10% of a day which is not 10 minutes. You're probably thinking of second.millisecond precision wherein 0.1 or 10% of a second correctly converts to 100 milliseconds.
-
Aug 22nd, 2008, 09:04 AM
#5
Hyperactive Member
Re: Adding to a date?
 Originally Posted by Teseng
Perfect, thanks much Arachnid.
No problem
Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|