LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Here's an Easy One


moon wrote:
Or this...

Sub Test()
Dim myVar As Single
Dim myDate As Date
myVar = 0.96
myDate = "9/29/06 12:33"
MsgBox myDate + myVar
End Sub


I didn't know it was that simple. I assumed that the OP was getting a
type-mismatch error (else why all this concern about type conversion?)
- so I typed "date" in Help and saw the DateAdd function and thought
"bingo". I seldom play around with dates in my code - learn something
new every day.

-semiopen


"Kevin" schreef in bericht
...
Try this:

Sub test()

Dim myVar As Single
Dim myDate As Date
Dim myResult As Date
Dim myMinutes As Long


myVar = 0.96
myMinutes = Round(myVar * 24 * 60) 'myVar times # of minutes in a day
myDate = "9/29/06 12:33"
myResult = DateAdd("n", myMinutes, myDate)
MsgBox myResult

End Sub

-------------------------------------

I don't know if there is a more elegant way

-semiopen


Worked like a charm. Never knew about the dateadd function. Things like
timevalue, datevalue, and cdate are all over the place. Thank you!

-Kevin


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy one... but not for me :S ChrisMattock Excel Worksheet Functions 7 July 3rd 06 09:49 PM
probably easy but.... obion Excel Worksheet Functions 3 October 7th 05 07:08 PM
Probably easy but I need help! djbob2k2 Excel Worksheet Functions 1 September 19th 05 01:44 AM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
Easy but not for me!! Lynda Excel Programming 3 February 16th 05 08:48 PM


All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"