0

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

3
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by infinity4ever
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

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:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.