August 20, 2002 at 3:30 pm
I have an .asp application that writes date and time in different columns in a table, but they were writing into columns that were just text. Now the columns are smalldatetime. How do I get the one column to just write the time and just get one to write the date.
Right now the date column writes the date and the time column writes 1/1/1900 TIME (TIME = the time the entry was created).
Anyone got any ideas?
Thanx,
Mischa
August 20, 2002 at 4:44 pm
Yup, smalldatetime has a date part. If you don't specify it you get 1/1/1900.
Probably you want to either ignore the date portion of that column when using it or (more in keeping with usual practice) stop using two columns to store a single piece of information.
August 21, 2002 at 11:28 am
OK. Thank you very much for your help.
If I did want to force the column to write only the time or only the date, but not the time, how do I do that?
For example, I want the column to only show 04:00:00 am. Or, if I wanted to show only the day and month, 06/08, etc
How does one do that?
Thanx a lot,
Mischa
August 21, 2002 at 11:47 am
Try this:
DECLARE @datetime datetime
SET @datetime = getdate()
SELECT @datetime, LEFT(CONVERT(varchar(10), @datetime, 103),5), CONVERT(varchar(10), @datetime, 108)
Robert Marda
SQL Server will deliver its data any way you want it
when you give your SQL Programmer enough developing time.
Robert W. Marda
Billing and OSS Specialist - SQL Programmer
MCL Systems
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply