文章出處

public static string retunSQl(string s,string e){
            
            return @"IF (
                    "+s+ ">" +e+ @",
                    DATEDIFF(" + e + @", " + s + @") - FLOOR(
                        ABS(
                            DATEDIFF(
                                subdate(
                                    " + e + @",
                                    date_format(" + e + @", '%w') - 1
                                ),
                                 " + s + @"
                            ) / 7 *- 1
                        )
                    ) * 2 *- 1,
                    DATEDIFF(" + e + @",  " + s + @") - FLOOR(
                        ABS(
                            DATEDIFF(
                                subdate(
                                    " + s + @",
                                    date_format( " + s + @", '%w') - 1
                                ),
                                " + e + @"
                            ) / 7 *- 1
                        )
                    ) * 2
                )";
        }

使用方法:
retunSQl("2016-4-12","2016-4-14");
2天
retunSQl('2016-4-12','2016-4-18');
4天
不算周末


 

 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()