Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
i wanted to ask if there was some way to get the server date from a Microsoft Access database.

I know about Date() and Time() methods, but in SELECT they give me local time. Can you give some help with this?
Posted
Updated 4-Feb-23 9:40am

What do you mean? Are you trying to retrieve remote server date/time using Access Database? If so, I don't think that would be possible.

If you are running the database in your local machine, and you intend to deploy it to the server, don't worry, it will return you the server data/time once you connect to it and execute the query.
 
Share this answer
 
If it is a local server you can, try this procedure

Private Sub btnServidorLocal_Click()

' Reference Windows Script Host Object Model

Dim cmdShell As New WshShell
Dim cmdEjecute As WshExec
Dim cmdInstruccion, hora, dia, tem As String

cmdInstruccion = "net time \\192.168.56.1"

Set cmdEjecute = cmdShell.Exec("%comspec% /c" & cmdInstruccion)

cmdInstruccion = cmdEjecute.StdOut.ReadAll

tem = Mid(cmdInstruccion, InStr(1, cmdInstruccion, Chr(47)) - 2, 18)

dia = Mid(tem, 1, 10)
hora = Format(Right(tem, 8), "hh:mm:ss AM/PM")

Me.fecha = CDate(dia)
Me.ctlhora = CDate(hora)

End Sub
 
Share this answer
 
Comments
Dave Kreskowiak 4-Feb-23 20:08pm    
I doubt the OP is still working on this 12 years later.

On top of that, there is no such thing as a Microsoft Access database SERVER. Access is a desktop database, so the "server" is the machine running the code accessing the database.

Your code is very convoluted when a call to DateTime.Now would suffice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900