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 > Advice on 'datetime year to date' for novice

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-21-10, 10:17
dmac25 dmac25 is offline
Registered User
 
Join Date: Jul 2009
Posts: 28
Advice on 'datetime year to date' for novice

My table has a date field defined as ‘datetime year to second’
When selected, it looks like “2009-08-31 10:55:27”.
I have never seen this date definition before.
My query needs to retrieve all rows whose date is yesterday,
dropping hour, minute, & second.
Can anyone advise me of the syntax ?
Many thanks
Reply With Quote
  #2 (permalink)  
Old 04-21-10, 10:27
bigcalm bigcalm is offline
Registered User
 
Join Date: Jul 2009
Posts: 37
The simplest way to do that is to use the date function, e.g.

select date(your_datetimefield)
from your_table
where date(your_datetimefield) = (TODAY -1)
Reply With Quote
  #3 (permalink)  
Old 04-22-10, 02:47
dmac25 dmac25 is offline
Registered User
 
Join Date: Jul 2009
Posts: 28
Advice on 'datetime year to date' for novice

thanks bigcalm
this works a treat.
best wishes
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