Start New Discussion Reply to this Discussion Date and Time
hi
i want to insert the current date and time in the sql server database... but i dont know how or what is the formulla exactly..i tried several time but all failed...
basicly what i want is when someone log in the site with the membership the session("Date") will be created, the date and time will be recorded in the sql server database in column date which has a data type of smalldatetime
can anyone help me whith this plz
infinity4ever
Newbie Poster
22 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
if you want to have the database match exactly the session date, you will need to pass it in, otherwise, if it can be off by a few seconds(or minutes) then you can simply use the getdate() function in sql.
Post one of your failed attempts and let's see if we can fix it
campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
Skill Endorsements: 0
In the ASP.NET page do something like this
(Assuming your data entry for date is a calendar).. it is the principle / logic here that matters.. not the methods
Session("Date") = Calendar1.Selected + " " + DateAndTime.TimeOfDay
'....
'....
cmd.commandText = "UPDATE tblName " _
SET dtm_column = CAST('" & CStr(Session(Date")) & "' AS smalldatetime)
WHERE blah = blah ...
example of this in SQL Server
SELECT CAST('2000-05-08 12:35:29.998' AS smalldatetime)
go
Result: 2000-05-08 12:35:00
Hope this helps
:cool:
Paladine
Master Poster
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
Skill Endorsements: 0
Thanks alot it works with me now :D
infinity4ever
Newbie Poster
22 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0610 seconds
using 2.66MB