久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將一天的名稱轉(zhuǎn)換為其整數(shù)表示

Converting the name of a day to its integer representation(將一天的名稱轉(zhuǎn)換為其整數(shù)表示)
本文介紹了將一天的名稱轉(zhuǎn)換為其整數(shù)表示的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號(hào)..

在 SQL Server 中,您可以使用 DATENAME 函數(shù)以字符串形式獲取星期幾

In SQL server you can use the DATENAME function to get the day of week as a string

declare @date datetime
set @date = '12/16/08'
select datename(dw, @date)

返回星期二"

并且您可以使用 DATEPART 函數(shù)以整數(shù)形式獲取星期幾

and you can use the DATEPART function to get the day of week as an integer

declare @date datetime
set @date = '12/16/08'
select datepart(dw, @date)

返回 3

但是假設(shè)我有一個(gè)包含字符串Tuesday"的 varchar,我想將它轉(zhuǎn)換為 3 的整數(shù)表示.當(dāng)然,我可以毫不費(fèi)力地寫出轉(zhuǎn)換,但我更愿意使用內(nèi)置的- 在功能.有這樣的功能嗎?

But say I have a varchar that contains the string "Tuesday" and I want to convert it to its integer representation of 3. Sure, I could write out the conversion without much hassle, but I'd much rather use a built-in function. Does such a function exist?

推薦答案

與其編寫函數(shù),不如創(chuàng)建一個(gè)包含說(shuō)明和數(shù)值的星期幾表.然后您可以簡(jiǎn)單地加入表格以獲取數(shù)字.

Rather than write a function, you should create a days of the week table with the description and the numeric value. THen you can simply join to the table to get the numeric.

如果您以多種方式存儲(chǔ)天數(shù)(可能在基于字符的系統(tǒng)中),您可以將所有變體放入表中,因此 TUE、Tues.、Tuesday 都將映射到相同的整數(shù).

And if you have days stored multiple ways (likely in a characterbased system), you can put all the variants into the table, so TUE, Tues., Tuesday would all map to the same integer.

這篇關(guān)于將一天的名稱轉(zhuǎn)換為其整數(shù)表示的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應(yīng)該使用什么 SQL Server 數(shù)據(jù)類型來(lái)存儲(chǔ)字節(jié) [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數(shù)據(jù))
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
How to convert #39;2016-07-01 01:12:22 PM#39; to #39;2016-07-01 13:12:22#39; hour format?(如何將“2016-07-01 01:12:22 PM轉(zhuǎn)換為“2016-07-01 13:12:22小時(shí)格式?)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應(yīng)該返回“1?什么時(shí)候不能投射為日期?)
主站蜘蛛池模板: 美女黄网| 91xh98hx 在线 国产 | 9999视频 | 国内精品久久久久久久影视简单 | 精品久久九 | 国产精品欧美日韩 | 污污免费网站 | 一级黄色片在线看 | ww 255hh 在线观看 | 午夜av毛片 | 国产精品99久久久久久久久久久久 | 91久久视频 | 色综合久| 日本久久综合 | 天天久久 | 国产精品2区 | 懂色一区二区三区免费观看 | 久久伊人影院 | 成人不卡一区二区 | 黄 色 毛片免费 | 国产精品久久久久久久久久免费看 | 午夜视频一区 | 国产精品毛片无码 | 一级片在线观看 | 久久久www成人免费无遮挡大片 | 日韩精品一区二区三区中文在线 | 在线视频日韩 | 亚洲欧美中文日韩在线v日本 | 国产精品视频导航 | 色综合一区二区 | 亚洲午夜精品视频 | 成人教育av | 国产日韩欧美 | 精品美女 | 欧美亚洲国产一区二区三区 | 黄色一级大片在线免费看产 | 91精品国产综合久久小仙女图片 | 成人国产一区二区三区精品麻豆 | 欧美性大战久久久久久久蜜臀 | 激情亚洲 | 一区精品国产欧美在线 |