Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / September 2005



Tip: Looking for answers? Try searching our database.

Reading millisecnds from Current datatime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Su Man - 22 Sep 2005 09:44 GMT
Hi,

How should I extract milliseconds from Current DataeTime (Now function).
Please help me in doing this.

Thanks,
Su Man
Norm Cook - 22 Sep 2005 14:16 GMT
Something like:

Option Explicit
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As
SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Sub Form_Load()
Dim st As SYSTEMTIME
GetSystemTime st
'format anyway you desire
Debug.Print "Day of Week: " & WeekdayName(st.wDayOfWeek + 1) 'zero based
Debug.Print "Year: " & st.wYear
Debug.Print "Month: " & st.wMonth
Debug.Print "Day: " & st.wDay
Debug.Print "Hour: " & st.wHour
Debug.Print "Minute: " & st.wMinute
Debug.Print "Second: " & st.wSecond
Debug.Print "Millisecond: " & st.wMilliseconds
End Sub

> Hi,
>
[quoted text clipped - 3 lines]
> Thanks,
> Su Man
Su Man - 23 Sep 2005 11:19 GMT
Hi,

Th time being displayed is not the time what I am seeing in my computer. It
is showing the time some 6 hrs back.

Now time in my system is 15:48  but the code returns 10:16.
Can you please tell my why is it so? And how should I get the correct time?

thanks,
Subramanian DS

> Something like:
>
[quoted text clipped - 33 lines]
> > Thanks,
> > Su Man
Ken Halter - 23 Sep 2005 15:32 GMT
> Hi,
>
[quoted text clipped - 8 lines]
> thanks,
> Subramanian DS

Time zone.... The function you're using doesn't account for time zone info.

The header for your post says.....

Subject: Re: Reading millisecnds from Current datatime
Date: Fri, 23 Sep 2005 15:49:35 +0530

That "+0530" tells the system to adjust the time by 5 1/2 hours to "sync"
your system with the rest of the world.

Signature

Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..

Karl E. Peterson - 23 Sep 2005 18:01 GMT
> Th time being displayed is not the time what I am seeing in my
> computer. It is showing the time some 6 hrs back.
>
> Now time in my system is 15:48  but the code returns 10:16.
> Can you please tell my why is it so? And how should I get the correct
> time?

Like Ken said, that's a universal time you're seeing, and you need to localize it (if
that's what you want).  The easiest way to do that is using
SystemTimeToTzSpecificLocalTime.  Just pass NULL (ByVal 0&) as the first parameter.
Signature

Working Without a .NET?
http://classicvb.org/petition

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.