Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Time addition in SQL query
Wed, May 6 2009 3:55 PMPermanent Link

"Halim"
I have 3 fields fields:

Fieldname        Type
LastUsedDate  Date
LastUsedTime  TIME
MinutesLeft       Integer


I would like a query to get me the expiration datetime using the =
follwoing formula:
ExpirationDatetime =3D LastUsedDate+LastUsedTime+MinutesLeft
I want The ExpirationDatetime to be a timestamp field.

I can't figure out how to add minutes to a time field then concatenate =
the result with a date field to obtain a timestamp.

Thank you,
-Halim
Fri, May 8 2009 5:33 AMPermanent Link

"John Hay"
Halim
>I have 3 fields fields:

>Fieldname        Type
>LastUsedDate  Date
>LastUsedTime  TIME
>MinutesLeft       Integer


>I would like a query to get me the expiration datetime using the follwoing
formula:
>ExpirationDatetime = LastUsedDate+LastUsedTime+MinutesLeft
>I want The ExpirationDatetime to be a timestamp field.

How about

SELECT CAST(CAST(LastUsedDate AS CHAR(10))+' '+CAST(LastUsedTime AS CHAR(8))
AS TIMESTAMP)+(MinutesLeft*60000) FROM Table

John

Fri, May 8 2009 9:23 AMPermanent Link

"Halim"
I like it.
Thank you John,
-Halim
"John Hay" <j.haywithoutdot@crbsolutionsremoveallthis.co.uk> wrote in
message news:A9308167-2BCF-4340-902B-180CC5726603@news.elevatesoft.com...
> Halim
>>I have 3 fields fields:
>
>>Fieldname        Type
>>LastUsedDate  Date
>>LastUsedTime  TIME
>>MinutesLeft       Integer
>
>
>>I would like a query to get me the expiration datetime using the follwoing
> formula:
>>ExpirationDatetime = LastUsedDate+LastUsedTime+MinutesLeft
>>I want The ExpirationDatetime to be a timestamp field.
>
> How about
>
> SELECT CAST(CAST(LastUsedDate AS CHAR(10))+' '+CAST(LastUsedTime AS
> CHAR(8))
> AS TIMESTAMP)+(MinutesLeft*60000) FROM Table
>
> John
>
>
>
Image