467,074 Members | 882 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

Best method for storing a time in a MsSQL database?

100+
Hi,

I've recently been porting a little php / mysql script over to asp / mssql and I've got issues with the timestamp data type. With mysql i could easily insert 01:01:01 into the timestamp column, however mssql throws an error and whats the string passed in to be converted into a timestamp data type.

Is this the right datatype to use? I read somewhere that the timestamp column is readonly and is updated each time the record is updated, if this is the case then i shouldn't be using the timestamp column. But then I'm posed with the problem that when I select and display the records how do i sort them by the lowest time?

I'm creating a a highscores table, the lowest time being the highest score.

Here is my current mssqyl statement:
Expand|Select|Wrap|Line Numbers
  1.         sqlStatement = "INSERT INTO scores (name,email,usertime,milliseconds) VALUES('" & fName & "','" & fEmail & "',CAST('" & fTime & "' as timestamp),'" & fMilliseconds & "')"
  2.  
error:
Expand|Select|Wrap|Line Numbers
  1. Cannot insert a non-null value into a timestamp column. Use INSERT with a column list or with a default of NULL for the timestamp column.
  2.  
Thanks!
Aug 22 '08 #1
  • viewed: 878
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

15 posts views Thread by Joshua Beall | last post: by
6 posts views Thread by Tippy G | last post: by
5 posts views Thread by Andrew S. Giles | last post: by
reply views Thread by Anonieko Ramos | last post: by
9 posts views Thread by Luke Vogel | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.