Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the string function and time function in the SQL statement

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

What this article shares with you is about the string function and time function in the SQL sentence. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

String function

1. Case conversion

-- upper converted to uppercase

-- convert lower to lowercase select upper ('AsaR')

two。 Length

-- len word count

-- number of datalength bytes

3. Remove spaces before and after

-- rtrim removes the right space

-- ltrim removes the left space

4. String interception

Left ('string', 15) intercepts 15 bytes from the left

Right ('string', 15) intercepts 15 bytes from the right

-- SubString ('string', 5 # 5) starts with the 5 th byte on the left and intercepts 5 bytes 5. String substitution

Replace ('you', 'you','I') replace you with us

Time function

1. Get the current date-- getdate ()

2.100 days later-dateadd (day,100,getdate ())

3. Time difference function-- dateiff (year,'1990/10/11',getdate ())

4. Inquire about the year, month and day

-- year (time) to get the year

-- month (time) to get month

-- day (time) acquisition day

-- calculate the number of births in each year select year (birthday), count (*) from table group by year ([birthday])

5. Get the year, month, day, hour, minute and second of the date

Datepart (year, date)

Datepart (month, date)

Datepart (day, date)

Datepart (hour, date)

Datepart (minute, date)

Datepart (second, date)

These are the string functions and time functions in the SQL statement. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report