Bluehost.com Web Hosting $6.95

timestamp (possible with mysql?)

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 ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2007
Mur-su
 
Posts: n/a
Default timestamp (possible with mysql?)

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

Reply With Quote
  #2 (permalink)  
Old 02-22-2007
Paul Lautman
 
Posts: n/a
Default Re: timestamp (possible with mysql?)

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`


Reply With Quote
  #3 (permalink)  
Old 02-22-2007
Mur-su
 
Posts: n/a
Default Re: timestamp (possible with mysql?)

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

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0