Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

DateDiff

 
   Database Help (Home) -> mySQL RSS
Next:  DataGrid Button Click  
Author Message
Lofty

External


Since: Sep 29, 2003
Posts: 6



(Msg. 1) Posted: Tue Oct 14, 2003 8:25 pm
Post subject: DateDiff
Archived from groups: mailing>database>mysql, others (more info?)

Hi all.

I have to write an app that interacts with mySQL (I really must have done
some evil, evil stuff in a previous life to be landed with this!)

I need to work out the difference in days between values in the database and
the current date. "No problem," thought I , "I'll just use the SQL DATEDIFF
command." Heh! Well, the user interface I'm using didn't even recognise
DATEDIFF as being a function, so I decided to visit the mySQL website.

Their description of DATEDIFF is as follows:

------------------------
DATEDIFF(ARGUMENTS)
TIMEDIFF(ARGUMENTS)
[Rest of description to be added here]

NEED EXAMPLE
DATEDIFF() and TIMEDIFF() were added in MySQL 4.1.1.
------------------------

Wow! How helpful! I can't believe that they don't provided decent
documentation for their database server!

I had a quick Google, but couldn't find ANY pages describing how to use it,
only pages complaining about its non-existence in previous versions.

Can anyone help me here?

--
Lofty
http://www.brainache.demon.co.uk

- There are 10 types of people in this world:
Those who understand binary, and those who don't.

 >> Stay informed about: DateDiff 
Back to top
Login to vote
Jezebel

External


Since: Oct 31, 2003
Posts: 35



(Msg. 2) Posted: Wed Oct 15, 2003 4:34 pm
Post subject: Re: DateDiff [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Since date values are just doubles in disguise, you can do simple arithmetic
on them. The difference in days is just Date2 - Date1, plus one if the count
is inclusive. If the dates include time values (the decimal part) you'll
need to convert to integer first.


"Lofty" wrote in message

 > Hi all.
 >
 > I have to write an app that interacts with mySQL (I really must have done
 > some evil, evil stuff in a previous life to be landed with this!)
 >
 > I need to work out the difference in days between values in the database
and
 > the current date. "No problem," thought I , "I'll just use the SQL
DATEDIFF
 > command." Heh! Well, the user interface I'm using didn't even recognise
 > DATEDIFF as being a function, so I decided to visit the mySQL website.
 >
 > Their description of DATEDIFF is as follows:
 >
 > ------------------------
 > DATEDIFF(ARGUMENTS)
 > TIMEDIFF(ARGUMENTS)
 > [Rest of description to be added here]
 >
 > NEED EXAMPLE
 > DATEDIFF() and TIMEDIFF() were added in MySQL 4.1.1.
 > ------------------------
 >
 > Wow! How helpful! I can't believe that they don't provided decent
 > documentation for their database server!
 >
 > I had a quick Google, but couldn't find ANY pages describing how to use
it,
 > only pages complaining about its non-existence in previous versions.
 >
 > Can anyone help me here?
 >
 > --
 > Lofty
<font color=purple> > <a rel="nofollow" style='text-decoration: none;' href="http://www.brainache.demon.co.uk</font" target="_blank">http://www.brainache.demon.co.uk</font</a>>
 >
 > - There are 10 types of people in this world:
 > Those who understand binary, and those who don't.
 >
 >
 >
 >

 >> Stay informed about: DateDiff 
Back to top
Login to vote
Lofty

External


Since: Sep 29, 2003
Posts: 6



(Msg. 3) Posted: Wed Oct 15, 2003 4:34 pm
Post subject: Re: DateDiff [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks for the response, Jezebel.

However, I tried your logic, and according to mySQL, December 1st 2003 -
October 15 2003 = -20030995062807

which doesn't make an awful lot of sense to me - it certainly isn't the
difference in days! Wink

Has anyone else managed to get the fabled mySQL DATEDIFF function to work?

--
Lofty
<a rel="nofollow" style='text-decoration: none;' href="http://www.brainache.demon.co.uk" target="_blank">http://www.brainache.demon.co.uk</a>

- There are 10 types of people in this world:
Those who understand binary, and those who don't.



"Jezebel" wrote in message

 > Since date values are just doubles in disguise, you can do simple
arithmetic
 > on them. The difference in days is just Date2 - Date1, plus one if the
count
 > is inclusive. If the dates include time values (the decimal part) you'll
 > need to convert to integer first.
 >
 >


  > > Hi all.
  > >
  > > I have to write an app that interacts with mySQL (I really must have
done
  > > some evil, evil stuff in a previous life to be landed with this!)
  > >
  > > I need to work out the difference in days between values in the database
 > and
  > > the current date. "No problem," thought I , "I'll just use the SQL
 > DATEDIFF
  > > command." Heh! Well, the user interface I'm using didn't even
recognise
  > > DATEDIFF as being a function, so I decided to visit the mySQL website.
  > >
  > > Their description of DATEDIFF is as follows:
  > >
  > > ------------------------
  > > DATEDIFF(ARGUMENTS)
  > > TIMEDIFF(ARGUMENTS)
  > > [Rest of description to be added here]
  > >
  > > NEED EXAMPLE
  > > DATEDIFF() and TIMEDIFF() were added in MySQL 4.1.1.
  > > ------------------------
  > >
  > > Wow! How helpful! I can't believe that they don't provided decent
  > > documentation for their database server!
  > >
  > > I had a quick Google, but couldn't find ANY pages describing how to use
 > it,
  > > only pages complaining about its non-existence in previous versions.
  > >
  > > Can anyone help me here?
  > >
  > > --
  > > Lofty
<font color=green>  > > <a rel="nofollow" style='text-decoration: none;' href="http://www.brainache.demon.co.uk</font" target="_blank">http://www.brainache.demon.co.uk</font</a>>
  > >
  > > - There are 10 types of people in this world:
  > > Those who understand binary, and those who don't.
  > >
  > >
  > >
  > >
 >
 >
 >> Stay informed about: DateDiff 
Back to top
Login to vote
Lofty

External


Since: Sep 29, 2003
Posts: 6



(Msg. 4) Posted: Wed Oct 15, 2003 4:34 pm
Post subject: Re: DateDiff [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Heh!

Well, I've ended up using

TO_DAYS(departure_date) - TO_DAYS(CURDATE())

which works, but seems really, really nasty!

Is there a public.mysql.sucks newsgroup anywhere? Wink

--
Lofty
<a rel="nofollow" style='text-decoration: none;' href="http://www.brainache.demon.co.uk" target="_blank">http://www.brainache.demon.co.uk</a>

- There are 10 types of people in this world:
Those who understand binary, and those who don't.



"Lofty" wrote in message

 > Thanks for the response, Jezebel.
 >
 > However, I tried your logic, and according to mySQL, December 1st 2003 -
 > October 15 2003 = -20030995062807
 >
 > which doesn't make an awful lot of sense to me - it certainly isn't the
 > difference in days! Wink
 >
 > Has anyone else managed to get the fabled mySQL DATEDIFF function to work?
 >
 > --
 > Lofty
<font color=purple> > <a rel="nofollow" style='text-decoration: none;' href="http://www.brainache.demon.co.uk</font" target="_blank">http://www.brainache.demon.co.uk</font</a>>
 >
 > - There are 10 types of people in this world:
 > Those who understand binary, and those who don't.
 >
 >
 >


  > > Since date values are just doubles in disguise, you can do simple
 > arithmetic
  > > on them. The difference in days is just Date2 - Date1, plus one if the
 > count
  > > is inclusive. If the dates include time values (the decimal part) you'll
  > > need to convert to integer first.
  > >
  > >


   > > > Hi all.
   > > >
   > > > I have to write an app that interacts with mySQL (I really must have
 > done
   > > > some evil, evil stuff in a previous life to be landed with this!)
   > > >
   > > > I need to work out the difference in days between values in the
database
  > > and
   > > > the current date. "No problem," thought I , "I'll just use the SQL
  > > DATEDIFF
   > > > command." Heh! Well, the user interface I'm using didn't even
 > recognise
   > > > DATEDIFF as being a function, so I decided to visit the mySQL website.
   > > >
   > > > Their description of DATEDIFF is as follows:
   > > >
   > > > ------------------------
   > > > DATEDIFF(ARGUMENTS)
   > > > TIMEDIFF(ARGUMENTS)
   > > > [Rest of description to be added here]
   > > >
   > > > NEED EXAMPLE
   > > > DATEDIFF() and TIMEDIFF() were added in MySQL 4.1.1.
   > > > ------------------------
   > > >
   > > > Wow! How helpful! I can't believe that they don't provided decent
   > > > documentation for their database server!
   > > >
   > > > I had a quick Google, but couldn't find ANY pages describing how to
use
  > > it,
   > > > only pages complaining about its non-existence in previous versions.
   > > >
   > > > Can anyone help me here?
   > > >
   > > > --
   > > > Lofty
<font color=brown>   > > > <a rel="nofollow" style='text-decoration: none;' href="http://www.brainache.demon.co.uk</font" target="_blank">http://www.brainache.demon.co.uk</font</a>>
   > > >
   > > > - There are 10 types of people in this world:
   > > > Those who understand binary, and those who don't.
   > > >
   > > >
   > > >
   > > >
  > >
  > >
 >
 >
 >> Stay informed about: DateDiff 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..

MySQL freezes, brings XP machine to a grinding halt - I've been using MySQL for a while for fairly light database development on my XP machine. Currently, I am just starting a new project and have experienced some big problems with MySQL today both on my office machine and at home where running a particular...

login as user 'root' but do not have root privlages and my.. - Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via..

FLUSH TABLES hangs if table is locked - Using FLUSH TABLES via the C query API mysql_query() hangs if the table is locked already. That is to say, nothing prevents me from running a LOCK TABLES twice; it won't tell me "it's already locked, don't try to run a FLUSH". Anyone know ...

Tool to convert DDL in graphical diagram? - Does anyone know of a tool that will create a graphical diagram from a DDL (SQL create script)? Preferable a free open-source tool. Thanks, A
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]