See: DATE_ADD(date,INTERVAL expr type) DATE_SUB(date,INTERVAL expr type) ADDDATE(date,INTERVAL expr type) SUBDATE(date,INTERVAL expr type)
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > m] On Behalf Of [EMAIL PROTECTED] > Sent: Wednesday, November 28, 2001 3:50 PM > To: [EMAIL PROTECTED] > Subject: Re: Proposal for two (or more) new time and date functions > > > > I think while you've got the hood up, a better method of > doing the difference between two dates should be derived. > > Unless I'm going about this all wrong, the only way to get > the time difference between two values currently is: > > UNIX_TIMESTAMP(end_datetime) - UNIX_TIMESTAMP(start_datetime) > > Wouldn't something like SECONDS_DIFF(start,end) make more > sense? Or perhaps TIME_DIFF(start,end)? > > I'm doing a lot of timekeeping control and I end up with this > code A LOT in my queries: > > SELECT > SUM(UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time))/3600 > AS hours > > Not to cite a MS product as useful, but the Jet design allows > (for good or > bad) the ability to do [date]-[otherdate] directly in SQL. > Since their dates are expressed internally as floating point, > [date]+1 is actually tomorrow. I personally prefer > seconds... I'd certainly like [date]-[date2] and [date]+86400 > in my book. > > > > Jeremy Zawodny <[EMAIL PROTECTED]> wrote: > > On Wed, Nov 28, 2001 at 12:21:38PM +0100, Thomas Spahni wrote: > > Hi! > > > > I am proposing two new functions for MySQL to make handling > of large > > timescales easy: > > > > TO_JD(date) and FROM_JD(double) > > > > These functions would convert DATETIME or DATE values to the 'Julian > date' > > and back. > > Personally, I think the names TO_JULIAN() and FROM_JULIAN() > might be better. Or even TO/FROM_JULIANDATE(). "JD" isn't > quite descriptive enough. But it'd certainly be a useful addition. > > Jeremy > -- > Jeremy D. Zawodny, <[EMAIL PROTECTED]> > Technical Yahoo - Yahoo Finance > Desk: (408) 349-7878 Fax: (408) 349-5454 Cell: (408) 685-5936 > > MySQL 3.23.41-max: up 83 days, processed 1,807,773,037 > queries (250/sec. > avg) > > > > > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php