dbTalk Databases Forums  

Convert int to datime

comp.databases.sybase comp.databases.sybase


Discuss Convert int to datime in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kjell Pettersen
 
Posts: n/a

Default Convert int to datime - 08-25-2004 , 05:46 AM






Hi!

Is it possible to convert an int field to datetime?

In one of our Sybase ASE DB there is a field called "time" of type int, and
it contains the
value 1093409123. In the application it looks like this is converted to
25.08.2004 06:45

Or is it so that Sybase cannot do this kind of conversation, so it is the
application who is doing this.

Kjell P.




Reply With Quote
  #2  
Old   
Jim Douglas
 
Posts: n/a

Default Re: Convert int to datime - 08-25-2004 , 06:22 AM






You are going to have to look at the application and see how it's
converting, number of seconds since 01/01/1970 or ????

"Kjell Pettersen" <kjell (AT) gpsgroup (DOT) cc> wrote

Quote:
Hi!

Is it possible to convert an int field to datetime?

In one of our Sybase ASE DB there is a field called "time" of type int,
and
it contains the
value 1093409123. In the application it looks like this is converted to
25.08.2004 06:45

Or is it so that Sybase cannot do this kind of conversation, so it is the
application who is doing this.

Kjell P.






Reply With Quote
  #3  
Old   
Michael Peppler
 
Posts: n/a

Default Re: Convert int to datime - 08-25-2004 , 07:10 AM



On Wed, 25 Aug 2004 12:46:51 +0200, Kjell Pettersen wrote:

Quote:
Hi!

Is it possible to convert an int field to datetime?

In one of our Sybase ASE DB there is a field called "time" of type int, and
it contains the
value 1093409123. In the application it looks like this is converted to
25.08.2004 06:45
That's most likely a "time_t" value. You can convert this to a datetime
value using the dateadd() function:

1> select dateadd(ss, 1093409123, 'jan 1 1970');

-------------------
Aug 25 2004 4:45AM

As you see this shows 4:45 insted of 6:45 as the time, because Sybase
doesn't understand timezones. The time_t value is in reference to
UTC, and my machine runs in European Summer Time at the moment.

Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler (AT) peppler (DOT) org http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.peppler.org/resume.html



Reply With Quote
  #4  
Old   
Bret Halford
 
Posts: n/a

Default Re: Convert int to datime - 08-25-2004 , 09:01 AM



"Kjell Pettersen" <kjell (AT) gpsgroup (DOT) cc> wrote

Quote:
Hi!

Is it possible to convert an int field to datetime?

In one of our Sybase ASE DB there is a field called "time" of type int, and
it contains the
value 1093409123. In the application it looks like this is converted to
25.08.2004 06:45

Or is it so that Sybase cannot do this kind of conversation, so it is the
application who is doing this.

Kjell P.
It is quite likely that this int value specifies an offset of <x> days
from some base date like 1/1/1900. You can verify this by taking the
values of some
known dates and using the dateadd() function to subtract <x> days from
the known datetime value - if they all give you the same date, that is
your base date. You can then convert any given int value to a
datetime using dateadd() to add <x> days to that base date.

Cheers,
-bret


Reply With Quote
  #5  
Old   
Bret Halford
 
Posts: n/a

Default Re: Convert int to datime - 08-25-2004 , 09:07 AM



"Kjell Pettersen" <kjell (AT) gpsgroup (DOT) cc> wrote

Quote:
Hi!

Is it possible to convert an int field to datetime?

In one of our Sybase ASE DB there is a field called "time" of type int, and
it contains the
value 1093409123. In the application it looks like this is converted to
25.08.2004 06:45

Or is it so that Sybase cannot do this kind of conversation, so it is the
application who is doing this.

Kjell P.
Looking at it a little closer - there is a time component, so
probably not days, but maybe minutes or seconds or milliseconds
or 1/300th seconds - compare a few known values to get a feel for
the size of the unit being used.

Cheers,
-bret


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.