Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to pull Sql Server time to my access app...Help!

Status
Not open for further replies.

Labadore

Programmer
Apr 13, 2001
17
US
I've created a timesheet app that will keep track of all employees during the day. When they clock in or out it uses the now() function to read the system time and inputs it into the fields. The employee's have decided they can change the system time to what they want then clock in. So what I need to do is somehow read the Sql Server date and time and input that into a field. If anyone knows how to do this or has done it before please let me know how.
Thank you in advance for all your time and help.

labadore
 
The GetDate function returns the current date/time in SQLS.

You can return it like so:
SET oConn=CREATEOBJECT("ADODB.CONNECTION")
SET oRS=CREATEOBJECT("ADODB.Recordset")

oConn.Open "MyDSN","MyUserName","MyPassword"
If oConn.State = 1 Then
SET oRS = oConn.Execute("SELECT GETDATE()")
MsgBox "SQLS Date/Time is: " & oRS.Fields(0).Value
End If

Or you could set the default value of the field in your SQLS table to Getdate(), so when you do your INSERT, the field is updated with the server time. Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top