|
-
November 28th, 1999, 10:20 AM
#1
How to insert date and time in SQL Server
Dear All,
Please guide me how to insert current date in one field and current time in another field in SQL server. I used CAST, it works with date (It works but I am not clear) but not work at all with time.
I selcted smalldatetime for date and timestamp for current time storage.
regards,
Santulan
-
November 29th, 1999, 12:19 AM
#2
Re: How to insert date and time in SQL Server
You can't use timestamp, as this is a binary value used internally by SQL server for the purposes of unique IDs.
I played around with this a bit, trying to use a date field to hold just the time also inserted either the current date or a 'dummy' date (e.g., 1/1/1900). Therefore, unless I am doing something wrong, I would recommend using a text field to hold the current time. In VB, you can get a string with the current time through Format(Now, "Long Time") (or "Medium Time" or "Short Time")
Charlie Zimmerman
http://www.freevbcode.com
-
November 29th, 1999, 03:21 PM
#3
Re: How to insert date and time in SQL Server
Why don't you try sendi the getdate() instruction to SQL, it will bring back the date and time
Regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|