On Mar 18, 4:21*am, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
Hi,
SQLServer 2005 doesn't support only Date, so no, you can only insert a
DateTime.Today to simulate only Date. *This will change with SQLServer 2008,
which supports Date, Time and DateTime and a few others as well.
--
Happy Coding!
Morten Wennevik [C# MVP]
"Saimvp" wrote:
Hello to all.
Please help me.
I'm inserting a date into sqlserver 2005 using C#3. my problem is while
insert is successfull my date and time.
It's possible to insert only a date?
--
To be Happy is To be Yourself- Hide quoted text -
- Show quoted text -
For what it is worth here are 2 UDF I have found that will set the
time portion to 12:00:00a and make comparisons work better. The second
one is more cryptic but supposedly faster.
/dg
-- #1
Create function [dbo].[DateOnly](@DateTime DateTime)
-- Returns @DateTime at midnight; i.e., it removes the time portion of
a DateTime value.
returns datetime
as
begin
return dateadd(dd,0, datediff(dd,0,@DateTime))
end
-- #2
CREATE FUNCTION [dbo].[GetDateElement]( @inDateTime as DATETIME )
RETURNS datetime AS
BEGIN
RETURN (select CAST(FLOOR( CAST(@inDateTime AS FLOAT ) )AS
DATETIME))
END