List:General Discussion« Previous MessageNext Message »
From:Douglas Brantz Date:June 4 2000 3:58pm
Subject:subtracting from timestamp
View as plain text  
I think this code will work for me.  I took it from the timestamp help page on
your website.

mysql> select totalsec, connectid, tdout from timedata where TO_DAYS(NOW()) -
TO_DAYS(tdout) <=3 and connectid="22";
+----------+-----------+----------------+
| totalsec | connectid | tdout          |
+----------+-----------+----------------+
| 00:00:33 | 22        | 20000603212323 |
| 00:00:19 | 22        | 20000603212353 |
| 00:00:56 | 22        | 20000604112510 |
+----------+-----------+----------------+
3 rows in set (0.00 sec)

the tdout is a timestamp and it looks like it is returning everything
correctly.

Thanks for listening and if anyone has a better way of doing this please let me
know.

Douglas

Douglas Brantz wrote:

> I am trying to use this code to help me: It doesn't work when  I try to
> subtract 6 days from today.
> It works if it stays within the same month - for example 2 works fine.??
> mysql> select date_format((curdate()-6),'%Y-%m-%d');
> +---------------------------------------+
> | date_format((curdate()-6),'%Y-%m-%d') |
> +---------------------------------------+
> | NULL                                  |
> +---------------------------------------+
> 1 row in set (0.00 sec)
>
> Am I going to have to figure this out with Unix Time or UNIX_TIMESTAMPS??
>
> Douglas Brantz wrote:
>
> > I have a timeclock program running with Mysql and would like to know if
> > its possible to do a simple subtraction on the timestamp.
> >
> > Basically when the admin wants to check time card history of the student
> > workers I have a drop down menu of all the students and then I would
> > like to have two choices 1. complete history and 2. how many days from
> > current day.
> >
> > 1.  With the complete history I can simply grab the timestamp when the
> > user was created and current date.
> >
> > 2.  WIth how many days back - say 1 week - is there an easy way to
> > subtract 7 days or 1 week from a current timestamp and I guess the
> > timestamp would be the current date/time?
> >
> > So,  Now( ) - 7 days?  and how would that be written out?
> > Then I need to grab the result of the created timestamp-7 days and
> > do a between statement show all records from student that fall between
> > the $now ( ) -7 days  and
> > Now( )?
> >
> > Thansk,
> >
> > Douglas
> >
> > --
> > ---------------------------------------------------------------------
> > Please check "http://www.mysql.com/php/manual.php3" before
> > posting. To request this thread, e-mail mysql-thread39276@stripped
> >
> > To unsubscribe, send a message to:
> >     <mysql-unsubscribe-brantzdr=appstate.edu@stripped>
>
> --
> ---------------------------------------------------------------------
> Please check "http://www.mysql.com/php/manual.php3" before
> posting. To request this thread, e-mail mysql-thread39278@stripped
>
> To unsubscribe, send a message to:
>     <mysql-unsubscribe-brantzdr=appstate.edu@stripped>

Thread
Question about subtracting from timestampDouglas Brantz4 Jun
  • Re: Question about subtracting from timestampDouglas Brantz4 Jun
    • RE: Question about subtracting from timestampSander Pilon4 Jun
  • RE: Question about subtracting from timestampSander Pilon4 Jun
  • Re: Question about subtracting from timestampDouglas Brantz4 Jun
  • subtracting from timestampDouglas Brantz4 Jun