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

Recommended Answers

All 3 Replies

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

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:

Thanks alot it works with me now :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.