Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to add date and time

Author  Topic 

mpolaiah
Starting Member

24 Posts

Posted - 2010-09-29 : 02:28:56
Hi alll,

i am using sql server 2005,
How to add date and time
for exampleeeeee

my date file is 2010-09-29 11:53:00
and add these file 01:00:00
these 2 filed added final i want 2010-09-29 12:53:00

please help mee

regards
pols

Sachin.Nand

2937 Posts

Posted - 2010-09-29 : 02:35:52
declare @dt datetime='2010-09-29 11:53:00'
declare @adddt datetime='01:00:00'
select @adddt + @dt


PBUH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-29 : 06:56:28
quote:
Originally posted by Sachin.Nand

declare @dt datetime='2010-09-29 11:53:00'
declare @adddt datetime='01:00:00'
select @adddt + @dt


PBUH




Assignment during declartion is not allowed in versions prior to 2008

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-29 : 07:00:38
Oh yes.I forgot.Here is SQL 2005 way

declare @dt datetime
set @dt='2010-09-29 11:53:00'
declare @adddt datetime
set @adddt='01:00:00'
select @adddt + @dt



PBUH

Go to Top of Page
   

- Advertisement -