欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Sybase中的日期時(shí)間函數_龍的天空
   今天做php項目的時(shí)候碰到一個(gè)問(wèn)題,經(jīng)過(guò)上網(wǎng)查找,找到了解決方法,特意記下來(lái),以備以后查找。問(wèn)題是保存在sybase數據庫中的時(shí)間格式是類(lèi)似"2007-06-18 14:12:30"這種格式的,但是當用php從數據庫中取出時(shí),格式變了,不是我想要的那種格式。于是上網(wǎng)查了一下sybase的日期時(shí)間函數,找到了sybase中常用的日期時(shí)間函數如下:

日期函數
getdate()
得到當前時(shí)間,可以設置得到各種時(shí)間格式.
datepart(日期部分,日期)
取指定時(shí)間的某一個(gè)部分,年月天時(shí)分秒.
datediff(日期部分,日期1,日期2)
計算指定的日期1和日期2的時(shí)間差多少.
dateadd(日期部分,數值表達式,日期)
計算指定時(shí)間,再加上表達式指定的時(shí)間長(cháng)度.

--取時(shí)間的某一個(gè)部分

select datepart(yy,getdate()) --year
select datepart(mm,getdate()) --month
select datepart(dd,getdate()) --day
select datepart(hh,getdate()) --hour
select datepart(mi,getdate()) --min
select datepart(ss,getdate()) --sec


--取星期幾

set datefirst 1
select datepart(weekday,getdate()) --weekday


--字符串時(shí)間

select getdate() -- ‘03/11/12‘
select convert(char,getdate(),101) -- ‘09/27/2003‘
select convert(char,getdate(),102) -- ‘2003.11.12‘
select convert(char,getdate(),103) -- ‘27/09/2003‘
select convert(char,getdate(),104) -- ‘27.09.2003‘
select convert(char,getdate(),105) -- ‘27-09-2003‘
select convert(char,getdate(),106) -- ‘27 Sep 2003‘
select convert(char,getdate(),107) --‘Sep 27, 2003‘
select convert(char,getdate(),108) --‘11:16:06‘
select convert(char,getdate(),109) --‘Sep 27 2003 11:16:28:746AM‘
select convert(char,getdate(),110) --‘09-27-2003‘
select convert(char,getdate(),111) --‘2003/09/27‘
select convert(char,getdate(),112) --‘20030927‘
select rtrim(convert(char,getdate(),102))+‘ ‘+(convert(char,getdate(),108)) -- ‘2003.11.12 11:03:41‘


--整數時(shí)間

select convert(int,convert(char(10),getdate(),112)) -- 20031112
select datepart(hh,getdate())*10000 + datepart(mi,getdate())*100 + datepart(ss,getdate()) -- 110646


--時(shí)間格式 "YYYY.MM.DD HH:MI:SS" 轉換為 "YYYYMMDDHHMISS"

declare @a datetime,@tmp varchar(20),@tmp1 varchar(20)
select @a=convert(datetime,‘2004.08.03 12:12:12‘)
select @tmp=convert(char(10),@a,112)
select @tmp
select @tmp1=convert(char(10),datepart(hh,@a)*10000 + datepart(mi,@a)*100 + datepart(ss,@a))
select @tmp1
select @tmp=@tmp+@tmp1
select @tmp



--當月最后一天

declare
@tmpstr varchar(10)
@mm int,
@premm int,
@curmmlastday varchar(10)
begin
select @mm=datepart(month,getdate())--當月
select @premm=datepart(month,dateadd(month,-1,getdate())) --上個(gè)月
if (@mm>=1 and @mm<=8)
select @tmpstr=convert(char(4),datepart(year,getdate()))+‘.0‘+convert(char(1),datepart(month,dateadd(month,1,getdate())))+‘.‘+‘01‘
else if (@mm>=9 and @mm<=11)
select @tmpstr=convert(char(4),datepart(year,getdate()))+‘.‘+convert(char(2),datepart(month,dateadd(month,1,getdate())))+‘.‘+‘01‘
else
select @tmpstr=convert(char(4),datepart(year,dateadd(year,1,getdate())))+‘.0‘+convert(char(1),datepart(month,dateadd(month,1,getdate())))+‘.‘+‘01‘
select @curmmlastday=convert(char(10),dateadd(day,-1,@tmpstr),102) --當月最后一天
end

     我自己組合了一下,利用(convert(char,PUBDATE,102)+‘ ‘+convert(char,PUBDATE,108)) AS PUBDATE先把數據庫中PUBDATE字段轉換成"2007.06.18 14:12:30"的格式,再利用php的str_replace函數把"."替換成"-",終于得到了我想要的類(lèi)似"2007-06-18 14:12:30”的日期格式。
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
關(guān)于SqlServer數據庫日期函數
T
Sql server中對時(shí)間類(lèi)型的字段轉換
SQLSERVER 時(shí)間格式大全_MsSql_腳本之家
SQL SERVER日期函數詳細用法
SQL DATEDIFF語(yǔ)法及時(shí)間函數
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久