Seniors, seniors, younger brother I am in the relative time of the related issues are disturbed, especially need your help, please help my brother I

Source: Internet
Author: User
Seniors, seniors, I was troubled by the question of time, especially in need of your help, please help me!
Attendance time storage format problem. I used the bigint to store the timestamp.
Limit: Credit card before 9 in the morning, credit card after 5:30, counted as not late and did not leave early.
Two tables were used for card check-in and swipe-back: Signin and SignOut.
The problems encountered are:
1. How can I determine whether he is late or early when the user has a credit card?
2. At the end of the month, how can I get all the records of his late and early departures this month?

It feels like a headache to compare time. Also hope that the predecessors pointed to me, thank you very much. I used the thinkphp MySQL.

The data table is defined as follows:

CREATE TABLE Ts_user
(wxname varchar () NOT NULL primary key,
Name varchar (NOT NULL),
Telnum Char (one) is not null unique,
Email varchar (unique),
Address varchar (100)
) Engine=innodb DEFAULT Charset=utf8;

CREATE TABLE Ts_signin
(Signid int NOT NULL Auto_increment primary key,
Wxname varchar () NOT NULL,
Date timestamp NOT NULL,
Location varchar (+) NOT NULL
) DEFAULT Charset=utf8;

CREATE TABLE Ts_signout
(Signid int NOT NULL Auto_increment primary key,
Wxname varchar () NOT NULL,
Date timestamp NOT NULL,
Location varchar (+) NOT NULL
) DEFAULT Charset=utf8;

ALTER TABLE Ts_signin add foreign key (Wxname) references Ts_user (wxname);
ALTER TABLE Ts_signout add foreign key (Wxname) references Ts_user (wxname);

I think on this side, can get the guidance of senior, thank you!
------to solve the idea----------------------

echo Date (' H ', Strtotime ("2015-01-27 09:01:10")); 9 pips
echo Date (' I ', Strtotime ("2015-01-27 09:01:10"));//01

------to solve the idea----------------------
Record data while judging late and early leave, and save as a new field
Timestamp at 9 o ' Day: strtotime (' y-m-d '). ' 09:00 ') compare to Time ()
------to solve the idea----------------------


CREATE TABLE Ts_user
(wxname varchar () NOT NULL primary key,
Name varchar (NOT NULL),
Telnum Char (one) is not null unique,
Email varchar (unique),
Address varchar (100)
) Engine=innodb DEFAULT Charset=utf8;

CREATE TABLE Ts_signin
(Signid int NOT NULL Auto_increment primary key,
Wxname varchar () NOT NULL,
Sdate Int (ten) is not NULL,
Chidao int (1) default 0, //1 is late, 0 is not late int or bool type is OK
Edate Int (ten) is not NULL,

Location varchar (+) NOT NULL //What's this about?
) DEFAULT Charset=utf8;

Direct select COUNT (Chidao) as Chidaoa from Ts_user,ts_signin, where Ts_signin.wxname =ts_user.wxname and (1 months of judgment)
Just like this, okay?
Add 1 data per day, late, leave early, all know, remember in every night 12 o'clock refresh, no sign-in, listed as late, or leave earlier, insert data section when directly written Chidao, leave to judge
------to solve the idea----------------------
I set up enough to the company's attendance machine, more complex, but also according to the user sub-department, Sub-time group; But overall, a user can only belong to a team of attendance and scheduling.

Time Machine also has a set, that is when to start judging for work, when to start judging for work, and then with the attendance schedule inside the commute time, or judge whether he was late or early.

The end of the month is relatively simple, know to get all the time to meet the attendance, such as you 9:00 to work, you put all the work attendance earlier than 9:01 minutes of attendance all listed, and then cycle the date, the way to remove the holiday time, natural, late came out
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.