J
Jozef Jarosciak
I need the function to tell me how many minutes past so far this month.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Jozef Jarosciak said:Dim minthismonth As Integer = DateDiff(DateInterval.Minute,
CType(("01/" & Date.Now.Month & "/" & Date.Now.Year), System.DateTime),
Now())
is showing result of : 272895
Which cannot be the truth. Today is 15th, so lets round it:
15(days) x 24(hours) x 60(minutes) = 21600 minutes
Result shouldnt be 272895, but little less than 21600.
Can someone see what is wrong with this code?
Thanks
Jozef Jarosciak
Rothariger said:i guess, this is it...
DateDiff(DateInterval.Minute, CType("01/" & Date.Now.Month & "/" &
Date.Now.Year, System.DateTime), Now())
Jozef said:Result shouldnt be 272895, but little less than 21600.
Can someone see what is wrong with this code?
Oenone said:ALWAYS use non-ambiguous date formats.
Jozef Jarosciak said:I need the function to tell me how many minutes past so far this month.
Jozef Jarosciak said:Dim minthismonth As Integer = DateDiff(DateInterval.Minute,
CType(("01/" & Date.Now.Month & "/" & Date.Now.Year), System.DateTime),
Now())
is showing result of : 272895
Which cannot be the truth. Today is 15th, so lets round it:
15(days) x 24(hours) x 60(minutes) = 21600 minutes
Result shouldnt be 272895, but little less than 21600.
Can someone see what is wrong with this code?
Thanks
Jozef Jarosciak
Jay B. Harlow said:Doh!
I should add: any month end may cause a problem, as the first Now may
return
12/31 while the second may return 1/1...
Jay
| Mythran,
| Of course if you call your function at Midnight on Dec 31st you may get
| really interesting results.
|
| The first Now, may return 31 Dec 2005, while the second & third Now
return
1
| Jan 2006, which would cause an entire years worth of minutes to be added
| in...
|
| I find Armin's example of storing Now in a separate variable to be much
more
| reliable & less likely to cause obscure bugs...
|
| Just a thought
| Jay
|
| ||
|| || > Dim minthismonth As Integer = DateDiff(DateInterval.Minute,
|| > CType(("01/" & Date.Now.Month & "/" & Date.Now.Year),
System.DateTime),
|| > Now())
|| >
|| > is showing result of : 272895
|| >
|| > Which cannot be the truth. Today is 15th, so lets round it:
|| > 15(days) x 24(hours) x 60(minutes) = 21600 minutes
|| >
|| > Result shouldnt be 272895, but little less than 21600.
|| > Can someone see what is wrong with this code?
|| >
|| > Thanks
|| > Jozef Jarosciak
|| >
||
|| Why use a string for DateDiff?
||
||
|| Public Function MinutesThisMonth() As Long
|| Return DateDiff( _
|| DateInterval.Minute, _
|| New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), _
|| DateTime.Now _
|| )
|| End Function
||
|| HTH,
|| Mythran
||
|
|

Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.