English 中文(简体)
5. 时间印记
原标题:SQL time stamp to millisecond

How can I convert SQL time using a datetime stamp to milliseconds. I am doing a highstock chart using VB.Net

这是我迄今为止的甄选守则。

    Dim mydatalist As New List(Of XyData)
    Dim sqlReader As SqlDataReader
    Dim strConn As New     SqlConnection(ConfigurationManager.ConnectionStrings("myCipConnection").ConnectionString)
    Dim strSql As String = "SELECT TOP 1000 DATEDIFF(second,{d  1970-01-  01 },dtmStamp)AS dtmStamp  ,dblReturnTemp  FROM tblCIPEventData  "
    Dim sqlCmd As New SqlCommand(strSql, strConn)
    strConn.Open()
    sqlReader = sqlCmd.ExecuteReader

<><><>>I>有一套甄选<>/strong><>>>。

Dim strSql As String = "SELECT TOP 1 dtmStamp ,dblReturnTemp   FROM tblCIPEventData"

The result looks like

2009-10-22 11:29:31.513

<><>>>> 我怎么能将这种信息转换成微秒。

最佳回答

列出你最初必须与其他日期比较的日期的周期。 减去两个日期之后,你将最后用一个时间点物体。 然后,时间范围物体可转换为微秒。 可以通过一条简单的法典来做到这一点:

Dim milliseconds As Double
milliseconds = (end - start).TotalMilliseconds
问题回答

http://support.microsoft.com/kb/186265

You can use the SQL Server DATEPART() function to get the milliseconds of a SQL Server datetime field returned to a Visual Basic application.

例:

SELECT Pubdate, DATEPART(Ms, Pubdate) FROM Titles

就我们的工作而言,我们使用了时间序列,即时间周期,我们做了以下工作:

CONVERT(BIGINT, DATEDIFF(s,  19700101 , left(a.mdate, 11)))*1000

The left(a.mdate, 11) gives data like = Apr 25 2012 (in readable format)

a.mdate = 2012-04-25 11:01:18.030

这是在规定的时间内。

这是我的工作:

me.labelDisplay.Text = CDate(query.dateColumn).ToString("yyyy-MM-dd HH:mm:ss.fff")

产出:

2017-03-23 16:35:08.237 

如果你想得到微秒部分的使用:

Dim ms as Integer = CDate(query.dateColumn).Milliseconds()




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?