using …

Pure C#

Archive for the ‘DateTime’ Category

Create a date with T-SQL

Posted by esersahin on 22/06/2010


http://stackoverflow.com/questions/266924/create-a-date-with-t-sql

Posted in DateTime, Transact-SQL | Leave a Comment »

T-SQL’s Datetime Data Type

Posted by esersahin on 22/06/2010


http://www.sqlmag.com/article/tsql3/t-sql-s-datetime-data-type.aspx

Posted in DateTime, Transact-SQL | Leave a Comment »

C# Date Time

Posted by esersahin on 28/08/2009


http://www.java2s.com/Tutorial/CSharp/0260__Date-Time/Catalog0260__Date-Time.htm

Posted in DateTime | Leave a Comment »

Convert DateTime

Posted by esersahin on 13/03/2009


CREATE PROCEDURE sproc_UpdateTemp_Sub
(
@PreviousDay datetime,
@PresentDay datetime
)
AS

select * from table1 where date between @previousday and @presentday

Go

CREATE PROCEDURE sproc_UpdateTemp
AS

DECLARE @PreviousDay datetime
DECLARE @PresentDay datetime

select @PresentDay = convert( datetime, convert( varchar(10), getdate(), 101 ))
select @PreviousDay = dateadd( day, -1, @PresentDay )

exec sproc_UpdateTemp_Sub @PreviousDay, @PresentDay

Go

Declare @presentday as varchar(10)
SET @PresentDay =  convert( varchar(10), getdate(), 101 )
select * from table where Convert( varchar(10), date1, 101)  = @presentday

Why are you using varchar instead of datetime datatype? If it is just to lose the time part of GetDate it is much more efficient convert it using a float.

Something like

select cast(floor(convert( float,getdate())) as datetime)

returns you today’s date with the time part set to 00:00:00.

You could create a UDT like this:

create function dbo.fnDateFromDateTime(@da

tetime datetime)
returns datetime
AS
begin
return cast(floor(convert( float,@datetime)) as datetime)
end

And call it like this:

select dbo.fnDateFromDateTime(GetDate())

Posted in Cast, Convert, DateTime, SQL, Sql Server, Transact-SQL | Leave a Comment »

Insert Null value into DateTime column in SQL server from ASPX application

Posted by esersahin on 29/11/2008


http://blogs.msdn.com/jaskis/archive/2008/07/09/insert-null-value-into-datetime-column-in-sql-server-from-aspx-application.aspx

Posted in DateTime, Null, SQL, Sql Server, Transact-SQL | Leave a Comment »

Enter Null Values for DateTime Column of SQL Server

Posted by esersahin on 28/11/2008


http://www.c-sharpcorner.com/UploadFile/sd_patel/EnterNullValuesForDateTime11222005015742AM/EnterNullValuesForDateTime.aspx

Posted in DateTime, Null, Sql Server | Leave a Comment »

DateTime Manipulation

Posted by esersahin on 10/11/2008


http://www.blackwasp.co.uk/CSharpDateManipulation.aspx

Posted in C#, DateTime | Leave a Comment »