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
 General SQL Server Forums
 New to SQL Server Programming
 Datetime format??????????

Author  Topic 

samsun125
Yak Posting Veteran

63 Posts

Posted - 2009-01-20 : 04:55:45
hi all,

from my stored procedure
i want to display datetime format like this:2009-01-20 15:10:08 +0530
but from my stored procedure i am getting 2008-12-17T00:00:00 this format.

i wrote sp like this:
in my table my date datatype is datetime.

ALTER proc GetLastModifiedDate
(
@TableName varchar(50)
)
as
begin
set nocount on

select Max(Date)from datetable where TableName =@TableName

end


thanks and regards
Rama

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-20 : 05:01:01
try this
select CONVERT(VARCHAR(19),Max(Date)+'5:30', 120) from datetable where TableName =@TableName

select convert(datetime,max(date)+'5:30') from datetable where tablename = @tablename
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-20 : 05:10:20
you always want to put 5:30 as time?
Go to Top of Page

samsun125
Yak Posting Veteran

63 Posts

Posted - 2009-01-20 : 05:11:30
no visakh16 +00:00 format
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-20 : 05:32:51
try this

ALTER proc GetLastModifiedDate
(
@TableName varchar(50)
)
as
begin
set nocount on

DECLARE @i DATETIME

SELECT @i = Max(Date)from datetable where TableName =@TableName

select convert( varchar(20), @i,120)+'+'+convert(char(5),getdate()-getutcdate(),108)

end
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-20 : 08:27:59
quote:
Originally posted by samsun125

no visakh16 +00:00 format


is this just for display purpose?
Go to Top of Page
   

- Advertisement -