December 22, 2004 at 2:56 pm
I will like to insert a date and time into a table
When getdate() is the value supplied the results have 1/1000th of second precision .Is there a way to truncate that?
When inserted on a sized char field the result is like Dec 22 2004 5:53AM
The secons this time are missing
Mike
December 22, 2004 at 6:17 pm
If you are inserting a date into a table, why are you not using a datetime field to store it?
If you want to select just the date part of getdate(), the following will do it for you:
select cast(floor(cast(getdate() as float)) as datetime)
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
December 23, 2004 at 1:21 am
A SmallDateTime field is accurate to the minute so setting it to GETDATE() will automatically truncate it for you.
December 23, 2004 at 3:16 am
If you want a specific format you could alway use something like
SELECT LEFT(CONVERT(varchar, GETDATE(), 113),17)
23 Dec 2004 10:04
Best regards,
Andrew
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply