|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Inserting time and comparing times
hey all,
I have a datetime field in a table, now whats the command to insert the current date and time down to milliseconds into a row of that field? (seconds would be fine, but the smaller the better) eg: id -> 1 logtime -> 12/10/2004 16:00:23:55 For this one i've tried: Code:
INSERT INTO tblSession ( logtime ) VALUES ( now() ) But this doesnt work, and that's what i do for mySQL databases, so i'm confused. My next question is, how do i compare to records in the database? What's the SQL Query? And i guess i'll throw in another question for good luck. In mysql there is an option to make an int field auto_increment, how do i do this in MS SQL? Thanks for your help in advance. |
|
#2
|
|||
|
|||
|
Code:
INSERT INTO tblSession ( logtime ) VALUES ( getdate() ) datetime columns are compared as any other columns. The equivivalent of auto_increment is the identity property. |
|
#3
|
|||
|
|||
|
thanks for that, but i have one more question.
Say i don't want to compare times as so much as see if a logtime is more than 15mins old? How would i do that? Thanks for your help |
|
#4
|
|||
|
|||
|
try with DATEDIFF, like
select case when datediff(mi, time1, time2) > 15 then 'on time' else 'out of time' end --------------------------- dev @ viewmoresoft.com tools for your database |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Inserting time and comparing times |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|