sql中獲取當前日期的函式怎麼寫只要月日)

2021-09-08 03:18:29 字數 1183 閱讀 9810

1樓:匿名使用者

1、使用getdate獲取當前日期。

2、用datename 分別獲取月份和日。

3、系統標準日期格式沒有**月**日,所以使用連線符'+',自定義格式。

2樓:

sql本身提供的系統日期函式是取不出這樣子格式的,只有自己合併字串,才可得到需要的格式

法一:select right(convert(varchar(6), getdate(),112),2)+'月'+right(convert(varchar(8), getdate(), 112),2)+'日'

法二:select convert(varchar(10),datepart(m,getdate()))+'月'+convert(varchar(10),datepart(d,getdate()))+'日'

法三:select substring(convert(varchar(8),getdate(),112),5,2)+'月'+substring(convert(varchar(8),getdate(),112),7,2)+'日'

3樓:匿名使用者

放在.net中可以嗎?

date.tostring("mm月dd日", datetimeformatinfo.invariantinfo)

個人建議不要放在資料庫裡 要不 將來有其他程式要使用這個記錄的時候,就不知道怎麼去轉化了

4樓:

一個語句寫不出來~用變數 + stuff函式 分別在5 和0後面插入新的字串

~你這想法好像是程式做的事

5樓:匿名使用者

select convert(varchar,month(getdate()))+'月'+convert(varchar,day(getdate()))+'日'

sql怎麼得到本月的一號到系統當前日期之間的資料

6樓:鐗單的鐬鐿

/*table 是你要查詢的表,ctime 是你要根據日期刷選的欄位,ctime 是datetime 型別

*/select * from tablewhere ctime>=(convert(varchar(7), getdate() , 120) + '-1')

and ctime<= getdate()

java怎麼獲取月的日期java怎麼獲取一個月的日期

calendar cal calendar.getinstance 不加下面2行,就是取當前時間前一個月的第一天及最後一天 cal.set calendar.year,2012 cal.set calendar.month,6 cal.set calendar.day of month,1 cal....

sql如何獲取字串中的指定字元

1 建立測試表,create table test int value varchar2 50 2 插入測試資料 insert into test int values qwer?d 234 insert into test int values afhkashf commit 3 查詢表中全量資料...

lua怎麼獲取函式的upvalue

lua中的函式是一階型別值 first class value 定義函式就象建立普通型別值一樣 只不過函式型別值的數專 據主要是一條條指屬 令而已 所以在函式體中仍然可以定義函式。假設函式f2定義在函式f1中,那麼就稱f2為f1的內嵌 inner 函式,f1為f2的 enclosing 函式,和內嵌...