This is a discussion on timestamp (possible with mysql?) within the MySQL Database forums, part of the Database Forums category; Hi, I'm not yet aware of all the possibilities with Mysql so I hope that you could enlighten me ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I'm not yet aware of all the possibilities with Mysql so I hope that you could enlighten me a bit :) My Problem: I have created a table where I have one colum for inserting "text" into and one for saving the date and time of this event with "timestamp". Now, I would like to read this "timestamp" from every row in a way that I get the number of days passed since. For example, If I have added some text at 2007-02-19 and I would be reading the table at 2007-02-22 the returning value would be 3. Is there a way to use Mysql this way or do I have to make some perl scripts for that? Best Wishes: Mur-su |
|
|||
|
Mur-su wrote:
> Hi, > I'm not yet aware of all the possibilities with Mysql so I hope that > you could enlighten me a bit :) > > My Problem: > I have created a table where I have one colum for inserting "text" > into and one for saving the date and time of this event with > "timestamp". > > Now, I would like to read this "timestamp" from every row in a way > that I get the number of days passed since. > For example, If I have added some text at 2007-02-19 and I would be > reading the table at 2007-02-22 the returning value would be 3. > > Is there a way to use Mysql this way or do I have to make some perl > scripts for that? > > Best Wishes: Mur-su You need the datediff() function as in: SELECT DATEDIFF(NOW(),`timefield`) FROM `table` |
|
|||
|
On 23 helmi, 00:14, "Paul Lautman" <paul.laut...@btinternet.com>
wrote: > Mur-su wrote: > > Hi, > > I'm not yet aware of all the possibilities with Mysql so I hope that > > you could enlighten me a bit :) > > > My Problem: > > I have created a table where I have one colum for inserting "text" > > into and one for saving the date and time of this event with > > "timestamp". > > > Now, I would like to read this "timestamp" from every row in a way > > that I get the number of days passed since. > > For example, If I have added some text at 2007-02-19 and I would be > > reading the table at 2007-02-22 the returning value would be 3. > > > Is there a way to use Mysql this way or do I have to make some perl > > scripts for that? > > > Best Wishes: Mur-su > > You need the datediff() function as in: > > SELECT DATEDIFF(NOW(),`timefield`) FROM `table`- Piilota siteerattu teksti - > > - Näytä siteerattu teksti - Ah, so simple and works perfectly : ) Thank you! - Mur-su |