If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > boring for datetime manipulation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-05, 08:29
wwwenjoy wwwenjoy is offline
Registered User
 
Join Date: Oct 2005
Posts: 2
Post boring for datetime manipulation

here the question bored me,I'm waiting for some advices

one table store exact hour in integer

teq(teq_time interger,----exact hour,such as 10 for 10:00:00
cond varchar(24))

extend(extend((current- interval(1) day to day),year to day),year to second) + teq_time;

eg,teq_time=10
such as current time is 2005-10-27 12:00:00
my procedure should return as 2005-10-26 10:00:00

cause interval () hour to second is not allowed in variable.

I wanna build one procedure to create time for execute another procedure.another procedure parameter is datetime year to second.

how can i do?
Reply With Quote
  #2 (permalink)  
Old 10-27-05, 15:28
June C. Hunt June C. Hunt is offline
Registered User
 
Join Date: Feb 2005
Posts: 43
If I understand correctly just what it is that you want to do, my best guess to help you out would be to try something like this:

extend(today - 1 units day, year to second) + teq_time units hour;

One of the problems you'll face with 'current' rather than 'today' is that you'll get the current time as well as the current date. Extending 'today' will give you zeros for hour to second so you will start with a clear time.

HTH.
Reply With Quote
  #3 (permalink)  
Old 10-27-05, 20:47
wwwenjoy wwwenjoy is offline
Registered User
 
Join Date: Oct 2005
Posts: 2
but teq_time is integer
I'd got one datetime year to second as a return
how to from today ,teq_time to reach a datetime datatype
Reply With Quote
  #4 (permalink)  
Old 10-28-05, 09:14
June C. Hunt June C. Hunt is offline
Registered User
 
Join Date: Feb 2005
Posts: 43
Did you try it? If not, try this to see for yourself how it works:

select extend(today - 1 units day, year to second)
from systables
where tabid = 1;

You will end up with: 2005-10-27 00:00:00



Now try this:

select extend(today - 1 units day, year to second) + 10 units hour
from systables
where tabid = 1;

You will have this:
2005-10-27 10:00:00

(Note that today is 28 October 2005.)

EXTEND is extending the DATE (today - 1 units day) to a DATETIME YEAR TO SECOND value. As you can see in the first returned expression, the HOUR TO SECOND value is 00:00:00. In the second expression I added "10 units hour". You would use the integer value stored in teq_time as the UNITS HOUR portion of the example.

In your original example, you used the CURRENT keyword to start with a DATETIME. That is not necessary. If you use the TODAY keyword instead, you'll get the results as shown above.

Does that help clear it up?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On