I have a date that is in the unix format (13 digits, not 10):
/Date(1561476867713)/
I want to convert that date within VB so that I can use it as a parameter for a SQL 'select' query:
SELECT TOP 1 *
FROM QB
WHERE QB.BOQ_ITEM_UID = 9950
AND QB.CONTRACT_UID = 0
AND QB.CONTRACTOR_UID = 3
AND QB.QUANTITY_BREAK = 200
AND QB.RATE_START_DATE = [converted date]
what the query should find (note the time is in milliseconds):
I have found various solutions but none that I could get to work for this particular situation. Using Visual Basic and SQL Server 2016.
EDIT: to demonstrate that the solution I have found to similar problems doesn't work:
Dim timeStamp = "1561476867713"
Dim unixConvertedDate As DateTime = New
System.DateTime(1970, 1, 1, 0, 0, 0, 0)
unixConvertedDate = unixConvertedDate.AddMilliseconds(timeStamp).AddHours(1)
This returns '#6/25/2019 04:34:27 PM#'. Now I need to change that to: '2019-06-25 16:34:27.713'
The issue is that '#6/25/2019 04:34:27 PM#' isn't displaying the milliseconds, only seconds, so I cannot format it to look like this: '2019-06-25 16:34:27.713'