Manning's Countdown to 2014
. Use discount code crdotd14 all month for 50% off every deal.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
mysql - get time interval
Joined: Nov 28, 2004
Nov 28, 2004 14:27:00
hello - this is probably pretty simple, but i was wondering if anyone had seen any examples of how to select something from a database based on a time interval.
for example, i have a number of records in a database, and I want to be able to pull all the ones out that have been created, say, less than one hour from the present time.
what is the best time/date format to stamp these things and what are the comparison methods like?
Joined: Feb 02, 2002
Nov 28, 2004 19:41:00
Hi Ian, welcome to JavaRanch.
This depends on the database you are using, and whether it supports arithmatic operators on date/time values, or has special methods to use with data/time.
In Oracle, you can just subtract two Dates, and it gives you the number of days(or the fraction of a day) between the two, which you can use in specifying your conditions.
The best place to start is the documentation for the database you are using.
The future is here. It's just not evenly distributed yet. - William Gibson
subject: mysql - get time interval
Converting millisecs to hour, minute, seconds.
auto-save from data when session times out
database equivalent for XML time
refresh a JPanel automatically with time
Duplicate Timers in JBOSS
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013