Date and Time

Reply

Join Date: Jun 2006
Posts: 22
Reputation: infinity4ever is an unknown quantity at this point 
Solved Threads: 0
infinity4ever infinity4ever is offline Offline
Newbie Poster

Date and Time

 
0
  #1
Jun 12th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Date and Time

 
0
  #2
Jun 12th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Date and Time

 
0
  #3
Jun 19th, 2006
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
  1. Session("Date") = Calendar1.Selected + " " + DateAndTime.TimeOfDay
  2.  
  3. '....
  4. '....
  5.  
  6. cmd.commandText = "UPDATE tblName " _
  7. SET dtm_column = CAST('" & CStr(Session(Date")) & "' AS smalldatetime)
  8. 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
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 22
Reputation: infinity4ever is an unknown quantity at this point 
Solved Threads: 0
infinity4ever infinity4ever is offline Offline
Newbie Poster

Re: Date and Time

 
0
  #4
Jun 21st, 2006
Thanks alot it works with me now
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1921 | Replies: 3
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC