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 > Extracting equivalent seconds from from "YYYY-MM-DD HH:MM"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-10, 08:05
chittu chittu is offline
Registered User
 
Join Date: Sep 2008
Posts: 5
Extracting equivalent seconds from from "YYYY-MM-DD HH:MM"

Hi All,

I'm struggling to find out a way to extract seconds equivalent of hour and minutes from datetime as a query output, for example:

fragment_col = '2010-05-26 14:30'


So some thing like -->

"select fragment_col from myTable where cond1=cond2"
output: '2010-05-26 14:30'

But expected output is 14*60+30=870

Any help appreciated.

Thanks
Sahoo
Reply With Quote
  #2 (permalink)  
Old 05-27-10, 05:13
chittu chittu is offline
Registered User
 
Join Date: Sep 2008
Posts: 5
Any help on this please.

Thanks
Sahoo
Reply With Quote
  #3 (permalink)  
Old 05-27-10, 07:14
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
After looking at the docs a little bit I can't find anything equivalent to an Hour() function, so you might have to tackle this a slightly harder way...

the TO_CHAR() function will convert the datetime in to a string, then you will have to use string manipulation to extract the relevant time portions, convert these back to integers and apply the necessary math.

Hope this helps
__________________
George
Twitter | Blog
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