Oracle Date type data Query Resolution example

Source: Internet
Author: User
Tags date sql query
oracle| Solution | data

CREATE TABLE Worklog_a (
Man_bar CHAR (8) Not NULL,
Man_name VARCHAR2 is not NULL,
MAN_DEP VARCHAR2 () not NULL,
Log_time Date not NULL
Status VARCHAR2 (40)
);
CREATE Unique INDEX Worklog_a_index
On Workman (Man_bar,man_name);
Comment on table worklog_a is
' Log on to the diary list ';

sql:= ' Select Man_bar as "attendance bar code", Man_name as "name", Log_time as "registration time", status as "status", MAN_DEP as "subordinate department";
sql:=sql+ ' from worklog_a where man_bar= ' + ' ' +s11+ '
           + ' and (To_char trunc (log_time, ' + ' ', ' dd ' + ') ' + ', ' + ' ' yyyy-mm-dd ' + ') between '
           + "+getdatestr" (DAT1. Date) + ' ' + ' and ' + ' + ' +getdatestr (dat2. Date) + ';
sql:=sql+ ') Order by log_time Desc ';
RunSQL (ado_pall,sql,0);

Function Tfrmain.getdatestr (dat:tdatetime): string;
var
  year, Month, Day:word
Begin
  Decodedate (dat,year,month,day);
  if (month>=10) then
        result:= inttostr (year) + '-' +inttostr ( Month)
  Else
        result:= inttostr (year) + '-' + ' 0 ' + inttostr ( Month);
  if (day>=10) then
      result:=result+ '-' +inttostr (day)
  Else
     result:=result+ '-' + ' 0 ' +inttostr (day);
End;

sql1:= ' INSERT into worklog_a values (';
sql1:=sql1+ ' +s1+ ', ' + ', ' + ', ' +s2+ ', ' + ', ' + ', ' +s3+ ', ' + ', ';
sql1:=sql1+ ' sysdate ' + ', ' + ' ' +kk+ ' ' + ') ';
RunSQL (ado_kqlog,sql1,1);
Statusbar1.simpletext:= ' Today's total: ' +inttostr (ADO_TM. recordcount+1) + ' attendance ';



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.