일일 업무일지 체크

Sql Query 

시간범위 체크

SELECT COUNT(*) as 'Count', [DailyReportID] FROM [DailyReport] WHERE [ProjectID]=4 AND [DATE] BETWEEN '2020-12-01 00:00:00' AND '2020-12-01 23:59:59' GROUP BY [DailyReportID]


C# asp.net

public void DailyReportDateCheck(string projectID, string date,out bool isExist,  out string reportID)

        {

            string[] day = date.Split('-');

            DateTime startDate = new DateTime(int.Parse(day[0]), int.Parse(day[1]), int.Parse(day[2]), 0, 0, 0);

            DateTime endDate = new DateTime(int.Parse(day[0]), int.Parse(day[1]), int.Parse(day[2]), 23, 59, 59);

            string query = "SELECT COUNT(*) AS 'Count' , [DailyReportID] FROM [DailyReport] WHERE [ProjectID]="+ projectID + " AND [DATE] BETWEEN '";

            query += String.Format("{0:yyyy-MM-dd HH:mm:ss}", startDate) + "' AND '";

            query += String.Format("{0:yyyy-MM-dd HH:mm:ss}", endDate) + "'";

            query += " GROUP BY [DailyReportID]";

            KawooDB kawoo = new KawooDB();

            DataTable db = kawoo.DbDataTable(query);

            int reportCount = int.Parse(db.Rows[0]["Count"].ToString());


            if (reportCount > 0)

            {

                isExist=true;

                reportID = db.Rows[0]["DailyReportID"].ToString();

            }

            else

            {

                isExist = false;

                reportID = String.Empty;

            }

        }

댓글

이 블로그의 인기 게시물

키스콘 건설업체 정보 서비스 (javascript, php)