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?

Signature
To be Happy is To be Yourself
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.

Signature
Happy Coding!
Morten Wennevik [C# MVP]
> 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?
Roger Frost - 18 Mar 2008 11:14 GMT
> 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.
Coming soon: more types! I love it!!!!!!!!!

Signature
Roger Frost
"Logic Is Syntax Independent"
DMG - 18 Mar 2008 15:21 GMT
On Mar 18, 4:21 am, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.com> wrote:
> Hi,
>
[quoted text clipped - 16 lines]
>
> - 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
The datetime type in SQL 2005 has both date and Time, but there is nothing to
stop you from inserting only the date part of that and having all the times
be the same (I think it ends up as midnight of that day).
Alternately, you COULD make a varchar which stores the date as a string.
That would kill date comparisons, but would allow you to store just the
date...
Ethan
> 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?