Home > Archive > ASE Database forum > April 2005 > comparing two datetime variables correctly









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 comparing two datetime variables correctly
VMI

2005-04-13, 8:24 pm

I'm having trouble comparing datetime variables and I was
wondering if there was any other better way to do it. For
example, if I have a datetime variable with '3/12/2005', I
will need to add ' 23:59.999' to this date in order to find
all the transactions that are less than or equal to this
date. Is there any better way to compare datetime
variables?

Thanks.
Mark A. Parsons

2005-04-13, 8:24 pm

add 1 day to '3/12/2005' and then test for transactions 'less than' the new
date (ie, '3/13/2005')

'3/12/2005' defaults to a time portion of '12:00AM' ... so adding 1 day to
'3/12/2005' will give you '3/13/2005' & '12:00AM'

VMI wrote:

> I'm having trouble comparing datetime variables and I was
> wondering if there was any other better way to do it. For
> example, if I have a datetime variable with '3/12/2005', I
> will need to add ' 23:59.999' to this date in order to find
> all the transactions that are less than or equal to this
> date. Is there any better way to compare datetime
> variables?
>
> Thanks.


Bret Halford

2005-04-13, 8:24 pm

Depends on just what you are really searching for

Rather than add hours, minutes, milliseconds, I'd write that as just

<dates> < "3/13/2005"


If you don't really need the time component at all in your data, you
might switch to using the new DATE datatype - it uses half the space.

-bret


VMI wrote:

> I'm having trouble comparing datetime variables and I was
> wondering if there was any other better way to do it. For
> example, if I have a datetime variable with '3/12/2005', I
> will need to add ' 23:59.999' to this date in order to find
> all the transactions that are less than or equal to this
> date. Is there any better way to compare datetime
> variables?
>
> Thanks.


VMI

2005-04-13, 8:24 pm

In the table, the transactions use the time sections. But
my process doesn't. So I can't eliminate the time part.

What do you mean with the new DAT type? I'm using SQL
Anywhere and it's not recognized.

> Depends on just what you are really searching for
>
> Rather than add hours, minutes, milliseconds, I'd write
> that as just
>
> <dates> < "3/13/2005"
>
>
> If you don't really need the time component at all in your
> data, you might switch to using the new DATE datatype - it
> uses half the space.
>
> -bret
>
>
> VMI wrote:
>
>

Bret Halford

2005-04-13, 8:24 pm

You are posting to the wrong newsgroup then - this
newsgroup is for ASE - Adaptive Server Enterprise.
For SQL Anywhere questions please post in sybase.public.sqlanywhere.*

Cheers,
-bret


VMI wrote:
[color=darkred]
> In the table, the transactions use the time sections. But
> my process doesn't. So I can't eliminate the time part.
>
> What do you mean with the new DAT type? I'm using SQL
> Anywhere and it's not recognized.
>

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