Professional Web Applications Themes

timestamp (possible with mysql?) - 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 ...

  1. #1

    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

    Mur-su Guest

  2. #2

    Default Re: timestamp (possible with mysql?)

    Mur-su wrote: 

    You need the datediff() function as in:

    SELECT DATEDIFF(NOW(),`timefield`) FROM `table`


    Paul Guest

  3. #3

    Default Re: timestamp (possible with mysql?)

    On 23 helmi, 00:14, "Paul Lautman" <com>
    wrote: 




    >
    > You need the datediff() function as in:
    >
    > SELECT DATEDIFF(NOW(),`timefield`) FROM `table`- Piilota siteerattu teksti -
    >
    > - Näytä siteerattu teksti -[/ref]

    Ah, so simple and works perfectly : )
    Thank you!

    - Mur-su

    Mur-su Guest

  4. #4

    Default Re: timestamp (possible with mysql?)

    On 22 Feb 2007 13:48:01 -0800, Mur-su wrote: 

    SELECT DATEDIFF(CURRENT_DATE, my_timestamp) FROM ....

    --
    32. I will not fly into a rage and kill a messenger who brings me bad news
    just to illustrate how evil I really am. Good messengers are hard to come by.
    --Peter Anspach's list of things to do as an Evil Overlord
    Peter Guest

Similar Threads

  1. Translating MySQL timestamp to datetime
    By Joshua Beall in forum PHP Development
    Replies: 1
    Last Post: April 22nd, 02:50 PM
  2. mysql date to timestamp
    By Ben in forum PHP Development
    Replies: 2
    Last Post: December 8th, 05:22 PM
  3. MySQL timestamp to desired date function
    By Cesar Aracena in forum PHP Development
    Replies: 2
    Last Post: September 18th, 11:39 AM
  4. mysql or php timestamp arithmatic
    By Christian Calloway in forum PHP Development
    Replies: 0
    Last Post: August 25th, 12:06 PM
  5. Help needed for TimeStamp conversion between MySQL and PHP
    By Andy Hassall in forum PHP Development
    Replies: 1
    Last Post: July 6th, 08:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139