Home > Archive > ASE Database forum > April 2005 > Date









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Date
teric

2005-03-30, 9:44 am

Hello,


How do I refer to ASE datetime data feild and only get the exact date? Are
there any function is Sybase that is like Oracle's TRUNC()? Also on instances
when time is near midnight time, date automatically round off to next day's
date. I dont want that to happen. Is there a way for me to prevent that from
happening?

Any help will be appreciated.


Thanks!


---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp
Raymond Mardle

2005-03-30, 9:44 am

Teric,
You can convert the datetime column to char / varchar
using the convert function. eg convert (varchar (8), getdate
(), 108) will return the time in hh:mm:ss format. Depending
upon the version of ASE you are using, depends upon which
values are available. But all versions will support 0 to 12
and 100 to 112. Please see the ASE manuals for full
descriptions of the formats but the one you may want is 109.

If you convert to just a date, it is the equivalent of
midnight on that date (i.e. 00:00:00).

Cheers

Raymond

> Hello,
>
>
> How do I refer to ASE datetime data feild and only get the
> exact date? Are there any function is Sybase that is like
> Oracle's TRUNC()? Also on instances when time is near
> midnight time, date automatically round off to next day's
> date. I dont want that to happen. Is there a way for me
> to prevent that from happening?
>
> Any help will be appreciated.
>
>
> Thanks!
>
>
> ---== Posted via the PFCGuide Web Newsreader ==---
> http://www.pfcguide.com/_newsgroups/group_list.asp

Bret Halford

2005-03-30, 9:44 am



teric wrote:

> Also on instances
> when time is near midnight time, date automatically round off to next day's
> date. I dont want that to happen. Is there a way for me to prevent that from
> happening?
>


Could you give an example of a value near midnight that rounds
to the next days date? I've never seen that happen...

1> create table datetest (x datetime)
2> go
1> insert datetest values ("1/1/2005 23:59:59:999")
2> go
(1 row affected)
1> select * from datetest
2> go
x
--------------------------
Jan 1 2005 11:59PM

(1 row affected)

Michael Peppler

2005-03-30, 9:44 am

On Mon, 21 Mar 2005 12:13:24 -0800, teric wrote:

> Hello,
>
>
> How do I refer to ASE datetime data feild and only get the exact date?
> Are there any function is Sybase that is like Oracle's TRUNC()? Also on
> instances when time is near midnight time, date automatically round off to
> next day's date. I dont want that to happen. Is there a way for me to
> prevent that from happening?


In addition to the other comments, if you are using 12.5.1 or later you
can convert to a date column:

select convert(date, my_date_time_column)
from ...

Michael
--
Michael Peppler [TeamSybase] mpeppler@peppler.org - http://www.peppler.org/
Sybase DBA/Developer
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html


Teric

2005-03-30, 9:44 am

This works for me. Thanks for the help.

> On Mon, 21 Mar 2005 12:13:24 -0800, teric wrote:
>
> next day's date. I dont want that to happen. Is there a
>
> In addition to the other comments, if you are using 12.5.1
> or later you can convert to a date column:
>
> select convert(date, my_date_time_column)
from ...
>
> Michael
> --
> Michael Peppler [TeamSybase] mpeppler@peppler.org -
> http://www.peppler.org/ Sybase DBA/Developer
> Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html
>
>

teric

2005-04-01, 8:04 pm

Bret,

this is happening in when using Powerbuilder to query or
view the data

> teric wrote:
>
> happening? >
>
> Could you give an example of a value near midnight that
> rounds to the next days date? I've never seen that
> happen...
>
> 1> create table datetest (x datetime)
> 2> go
> 1> insert datetest values ("1/1/2005 23:59:59:999")
> 2> go
> (1 row affected)
> 1> select * from datetest
> 2> go
> x
> --------------------------
> Jan 1 2005 11:59PM
>
> (1 row affected)
>

Bret Halford

2005-04-01, 8:04 pm

From another machine, perhaps? Could there be some difference
between the system clocks on the two machines?

-bret

teric wrote:
[color=darkred]
> Bret,
>
> this is happening in when using Powerbuilder to query or
> view the data
>

teric

2005-04-05, 8:06 pm

Bret,

Yes. Because our server is in Foster City, while we are
here in Florida. Any suggestion on that set up?


> From another machine, perhaps? Could there be some
> difference between the system clocks on the two machines?
>
> -bret
>
> teric wrote:
>
>

Bret Halford

2005-04-05, 8:06 pm

In general, try to avoid mixing times from two clocks.

The client can either get it's local clock time and insert that as a
literal value, or insert "getdate()" to get the server time. But
if you start mixing them and expecting perfect correlation, it isn't
going to work. In general, it is probably better to rely on the
server's time - because multiple clients will all have their own clocks
with differences between them as well - if everything is done with
the server's clock values, the entries will at least all be
self-consistent.

I also generally recommend running the server on GMT or universal
standard time; clients can be in all different time zones, so I suggest
always making the client responsible for converting from server time
to local time.

Cheers,
-bret

teric wrote:
[color=darkred]
> Bret,
>
> Yes. Because our server is in Foster City, while we are
> here in Florida. Any suggestion on that set up?
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com