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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve Current Date

Status
Not open for further replies.
Sep 21, 2001
28
US
Is there a way I can retrieve the system date and save it in the SQL table?

The user supposed to enter the customer info on a GUI form, after the user click submit, it saves the data to the SQL server table and one of the fields is CreateDate. Right now the date is saved as 1/1/1900. I want it to retrieve the system date and replaced it instead.

Here is the class to perform that function. Let me know if I'm missing anything.



Public Property Get CreateDate() As Date
CreateDate = m_dCreateDate
End Property ' get CreateDate

 
Use the Date funtion.
Code:
Debug.Print Date
Debug.Print Now

zemp
 
Or get the date from the SQL Server, incase users decide to mess around with there system date.


"SELECT GETDATE()"



Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Microsoft SQL Server also has the ability to supply system date and time.

An example SQL String to insert a record would be...

Insert Into Table(Field1, Field2, CreateDate)
Values (Value1, Value2, GetDate())

If the time that the record was inserted is important, then sql server's GetDate() function is the way to go. I've seen several computers on the same network have times that differ by several hours.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Wow... awesome. The quickest replies I've gotten. Thanks guys. You guys are the best.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top