溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

oracle日期如何轉(zhuǎn)換成星期

發(fā)布時間:2021-11-18 14:16:03 來源:億速云 閱讀:1373 作者:小新 欄目:關系型數(shù)據(jù)庫

這篇文章將為大家詳細講解有關oracle日期如何轉(zhuǎn)換成星期,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

現(xiàn)在有個數(shù)據(jù)分析的工作,需要分析網(wǎng)站注冊會員的一些情況:

1.工作日、工作時間注冊的的會員成為付費會員的比列,

2.工作日、非工作時間注冊的的會員成為付費會員的比列,

3,非工作日,非工作時間注冊的的會員成為付費會員的比列。

4,非工作日,工作時間注冊的的會員成為付費會員的比列

工作時間按:08:30到17:30

工作日:周一到周五。

查看工作日,工作時間的注冊會員總數(shù):

select  count(*) from member_info1234 where to_char(register_date,'d')>1 and to_char(register_date,'d')<7  and to_char(register_date,'HH24:mi:ss')>'08:00:00'  and to_char(register_date,'HH24:mi:ss')<'17:30:00';

注釋:先通過to_char(sysdate,'d') 來把日期轉(zhuǎn)換成星期的第幾天,具體對照關系如下:

星期日----1

星期一----2

。

。

星期六----7

然后to_char(register_date,'d')>1 and to_char(register_date,'d')<7 這樣就選擇出來了工作日。

工作時間就是利用to_char(register_date,'HH24:mi:ss')>'08:00:00'  and to_char(register_date,'HH24:mi:ss')<'17:30:00'選擇出來的。

前面四個需求的具體實現(xiàn)如下:

1.查看工作日,工作時間注冊的會員數(shù)

select  count(1) from member_info1234 where to_char(register_date,'d')>1 and to_char(register_date,'d')<7

and to_char(register_date,'HH24:mi:ss')>'08:00:00'  and to_char(register_date,'HH24:mi:ss')<'17:30:00';

2..查看工作日,非工作時間注冊的會員數(shù)

select  count(1) from member_info1234 where to_char(register_date,'d')>1 and to_char(register_date,'d')<7

and ((to_char(register_date,'HH24:mi:ss')<'08:00:00'  and to_char(register_date,'HH24:mi:ss')>'00:00:00')

or (to_char(register_date,'HH24:mi:ss')<'23:59:59'  and to_char(register_date,'HH24:mi:ss')>'17:30:00')) ;

3..查看非工作日,工作時間注冊的會員數(shù)

select  count(1) from member_info1234 where (to_char(register_date,'d')=1 or to_char(register_date,'d')=7)

and to_char(register_date,'HH24:mi:ss')>'08:00:00'  and to_char(register_date,'HH24:mi:ss')<'17:30:00';

4..查看非工作日,非工作時間注冊的會員數(shù)

select  count(1) from member_info1234 where (to_char(register_date,'d')=1 or to_char(register_date,'d')=7)

and ((to_char(register_date,'HH24:mi:ss')<'08:00:00'  and to_char(register_date,'HH24:mi:ss')>'00:00:00')

or (to_char(register_date,'HH24:mi:ss')<'23:59:59'  and to_char(register_date,'HH24:mi:ss')>'17:30:00'));

我們從這些數(shù)據(jù)比例如下:

1.工作日、工作時間注冊的的會員成為付費會員的比列,  ----50605, 805   比列為0.015

2.工作日、非工作時間注冊的的會員成為付費會員的比列,----12188 , 70      比列為0.0057

3,非工作日,工作時間注冊的的會員成為付費會員的比列。----7316, 82  比列為0.011

4,非工作日,非工作時間注冊的的會員成為付費會員的比列     ---2907  ,19 比列為0.0065

通過這些比例可以了解到在工作日和工作時間注冊的會員價值最高,成為付費會員的可能性越大,并且可能是因為有的單位周六日也上班,導致非工作日,工作時間注冊的的會員成為付費會員的比列是第二大的,總起來說就是在工作時間注冊的會員,成為付費會員的可能性比較大,可以去告訴業(yè)務人員去重點去發(fā)展,

關于to_char的一些常用的用法 :

Select to_char(sysdate,'ss') from dual取當前時間秒部分

Select to_char(sysdate,'mi') from dual取當前時間分鐘部分

Select to_char(sysdate,'HH24') from dual取當前時間秒小時部分

Select to_char(sysdate,'DD') from dual取當前時間日期部分

Select to_char(sysdate,'MM') from dual取當前時間月部分

Select to_char(sysdate,'YYYY') from dual取當前時間年部分

Select to_char(sysdate,'w') from dual取當前時間是一個月中的第幾周(從1日開始算)

Select to_char(sysdate,'ww') from dual取當前時間是一年中的第幾周(從1.1開始算)

Select to_char(sysdate,'iw') from dual取當前時間是一年中的第幾周(按實際日歷的)

Select to_char(sysdate,'d') from dual取當前時間是一周的第幾天,從星期天開始,周六結(jié)束

Select to_char(sysdate,'day') from dual 取當前日是星期幾,和數(shù)據(jù)庫設置的字符集有關,會輸出'Tuesday'

Select to_char(sysdate,'ddd') from dual 當前日是一年中的第幾天

關于“oracle日期如何轉(zhuǎn)換成星期”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI