Hi all,
So, I'm presented with a potential issue where I'm writing to a local database server in the UK but could have someone writing to the database from the US. I'm using a MS Access database which is proving to be a right pain in the backside when querying using date formats. My local PC running the client in the UK would display the 22nd of Nov as 22/02/2013. I'm assuming that a local PC running the client in America would be 02/22/2013. This could throw a wobbler when trying to query the access database.
So, I did some playing about and searching and found this solution:
I suspect that this will suffice. But first out of curiosity, is there an easier way to achieve what I want? I couldn't find anything online. As per the above code, I would just check the location of 22 and determine whether the date should be dd/mm/yyyy or mm/dd/yyyy.
If in fact what I'm doing is the correct way, could someone that lives in the US please have a go at the above code? I would expect the msgbox to display '11/22/2013'
Many thanks!
So, I'm presented with a potential issue where I'm writing to a local database server in the UK but could have someone writing to the database from the US. I'm using a MS Access database which is proving to be a right pain in the backside when querying using date formats. My local PC running the client in the UK would display the 22nd of Nov as 22/02/2013. I'm assuming that a local PC running the client in America would be 02/22/2013. This could throw a wobbler when trying to query the access database.
So, I did some playing about and searching and found this solution:
Code:
Private Function GetGmtExpressedAsLocal(ByVal gmtDate As Date) As Date
Return gmtDate.AddMinutes(GetMinuteOffsetFromGmt)
End Function
Private Function GetMinuteOffsetFromGmt() As Double
Dim NowTime As Date = Now
Dim NowAsGmt As Date = NowTime.ToUniversalTime
Return CType(DateDiff(DateInterval.Minute, NowAsGmt, NowTime), Double)
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim NovGmt As Date = New Date(2013, 11, 22, 0, 0, 0)
Dim Nov1AsLocal As Date = GetGmtExpressedAsLocal(NovGm
MsgBox(Nov1AsLocal)
End Sub
If in fact what I'm doing is the correct way, could someone that lives in the US please have a go at the above code? I would expect the msgbox to display '11/22/2013'
Many thanks!