Wednesday, March 7, 2012

convert seconds to datetime

Hi friends,
I want to convert datetime that is stored as seconds to the actual datetime.
Example
Expiredate is stored as seconds since 1/1/1970 (ctime)
Expiredate = 1200373200
convert this to actual datetime
Please help me to solve this. It is very urgent.
thanks
vanithavanitha try
declare @.Expiredate bigint
select @.Expiredate = 1200373200
select dateadd(s,@.Expiredate ,01/01/1970)
Regards
R.D
"vanitha" wrote:

> Hi friends,
> I want to convert datetime that is stored as seconds to the actual datetim
e.
> Example
> Expiredate is stored as seconds since 1/1/1970 (ctime)
> Expiredate = 1200373200
> convert this to actual datetime
> Please help me to solve this. It is very urgent.
> thanks
> vanitha
>|||or
declare @.Expiredate bigint
declare @.Ctime datetime
select @.Ctime ='01/01/1970'
select @.Expiredate = 1200373200
select dateadd(s,@.Expiredate ,@.Ctime)
"vanitha" wrote:

> Hi friends,
> I want to convert datetime that is stored as seconds to the actual datetim
e.
> Example
> Expiredate is stored as seconds since 1/1/1970 (ctime)
> Expiredate = 1200373200
> convert this to actual datetime
> Please help me to solve this. It is very urgent.
> thanks
> vanitha
>|||Thanks R.D
we shd put date inside the quotes otherwise its giving us wrong solution. I
don't know y.
example
declare @.Expiredate bigint
select @.Expiredate = 1200373200
select dateadd(s,@.Expiredate ,01/01/1970)
result : 1938-01-15 05:00:00.000
declare @.Expiredate bigint
select @.Expiredate = 1200373200
select dateadd(s,@.Expiredate ,'01/01/1970')
result : 2008-01-15 05:00:00.000
thanks
vanitha
"R.D" wrote:
> vanitha try
> declare @.Expiredate bigint
> select @.Expiredate = 1200373200
> select dateadd(s,@.Expiredate ,01/01/1970)
> Regards
> R.D
> "vanitha" wrote:
>|||you r right vanitha.
if you dont put inside quotes then it treats it as date out of range in sql
server. so starts from base date of sql server.
Regards
R.D
"vanitha" wrote:
> Thanks R.D
> we shd put date inside the quotes otherwise its giving us wrong solution.
I
> don't know y.
> example
> declare @.Expiredate bigint
> select @.Expiredate = 1200373200
> select dateadd(s,@.Expiredate ,01/01/1970)
> result : 1938-01-15 05:00:00.000
> declare @.Expiredate bigint
> select @.Expiredate = 1200373200
> select dateadd(s,@.Expiredate ,'01/01/1970')
> result : 2008-01-15 05:00:00.000
> thanks
> vanitha
>
> "R.D" wrote:
>|||vanitha
when you get help from news groups, It is your duty to check it as answer.
This will encourage people to answer more quetions. do read help availbe top
right corner.
Regards
R.D
"vanitha" wrote:

> Hi friends,
> I want to convert datetime that is stored as seconds to the actual datetim
e.
> Example
> Expiredate is stored as seconds since 1/1/1970 (ctime)
> Expiredate = 1200373200
> convert this to actual datetime
> Please help me to solve this. It is very urgent.
> thanks
> vanitha
>|||sure R.D.
I used to do it. this time i just replied back.
thnks
"R.D" wrote:
> vanitha try
> declare @.Expiredate bigint
> select @.Expiredate = 1200373200
> select dateadd(s,@.Expiredate ,01/01/1970)
> Regards
> R.D
> "vanitha" wrote:
>|||Vanithaji
I was talking generally, not for my post alone. Any way thanks for that.
Regards
R.D
"R.D" wrote:
> vanitha
> when you get help from news groups, It is your duty to check it as answer.
> This will encourage people to answer more quetions. do read help availbe t
op
> right corner.
> Regards
> R.D
> "vanitha" wrote:
>|||The date should really be expressed in "yyyymmdd hh:nn:ss.000" format as
it is unambiguous regardless of locale. For example:
dateadd(s, @.Expiredate, '19700101 00:00:00.000')
or
dateadd(s, @.Expiredate, '19700101')
*mike hodgson*
blog: http://sqlnerd.blogspot.com
vanitha wrote:
>Thanks R.D
>we shd put date inside the quotes otherwise its giving us wrong solution. I
>don't know y.
>example
>declare @.Expiredate bigint
> select @.Expiredate = 1200373200
> select dateadd(s,@.Expiredate ,01/01/1970)
>result : 1938-01-15 05:00:00.000
>declare @.Expiredate bigint
> select @.Expiredate = 1200373200
> select dateadd(s,@.Expiredate ,'01/01/1970')
>result : 2008-01-15 05:00:00.000
>thanks
>vanitha
>
>"R.D" wrote:
>
>|||Help in the top right corner? Only if you're using a web-based
newsreader such as
http://www.microsoft.com/technet/co...r&lang=en&cr=US
(Many of us use a real NNTP newsreader, like Mozilla Thunderbird or
Microsoft Outlook Express for example.) ;)
*mike hodgson*
blog: http://sqlnerd.blogspot.com
R.D wrote:
>vanitha
>when you get help from news groups, It is your duty to check it as answer.
>This will encourage people to answer more quetions. do read help availbe to
p
>right corner.
>Regards
>R.D
>"vanitha" wrote:
>
>

No comments:

Post a Comment