当前位置:网站首页>Five SQL functions for operation date that must be known in SQL tutorial
Five SQL functions for operation date that must be known in SQL tutorial
2022-06-23 10:08:00 【Knowledge fatness】
If you ask about the most important skills of a data scientist before I get my first job , My answer must be Python. without doubt !
I am now a data scientist , If you ask me the same question , My answer is still Python. however , I have a second thought . What makes me think twice is SQL.
SQL It is a necessary skill for data scientists . It is mainly used to query relational databases , But it can do more .SQL Equipped with so many functions , Make it an efficient data analysis and operation tool .
In this paper , We will introduce 5 For operation date SQL function . When processing data involving date or time-based information , They will come in handy .
Be careful : SQL Used by many relational database management systems , for example MySQL、SQL Server、PostgreSQL etc. . Although most of them use the same SQL grammar , But there may be subtle differences . In this paper , We will use SQL Server.
1. Get date
seeing the name of a thing one thinks of its function ,getdate Function gives us today's date . Let's take an example .
DECLARE @mydate Date
SET @mydate = GETDATE()
print @mydate
'2021-08-22'
Let's create a name “mydate” And specify its value as today's date .
2. Add date
The name of this function is more self explanatory than the previous one .dateadd Function to add a time or date interval to the date .
As usual , Syntax is easier to understand through examples .
DECLARE @mydate Date
SET @mydate = GETDATE()
SELECT DATEADD(MONTH, 1, @mydate) AS NextMonth
NextMonth
2021-09-22
</边栏推荐
猜你喜欢

ICLR 2022 | 视频中的动态卷积TAdaConv以及高效的卷积视频理解模型TAdaConvNeXt

Gstore weekly gstore source code analysis (IV): black and white list configuration analysis of security mechanism

我被提拔了,怎么和原来平级的同事相处?

Go string comparison

2022 gdevops global agile operation and maintenance summit - essence playback of Guangzhou station (with PPT download)

Typora set up image upload service

Go 单元测试

Personal blog system graduation project opening report

数学分析_笔记_第2章:实数与复数

NFTs、Web3和元宇宙对数字营销意味着什么?
随机推荐
基于STM32设计的宠物投喂器
多线程习题
thymeleaf如何取url中请求参数值?
Spring recruitment interview experience summary (technical post)
高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
Gorm advanced query
Successful experience in postgraduate entrance examination for MTI master of English translation major of Beijing University of science and technology in 2023
2021-05-11抽象类
pycharm安装教程,超详细
R和RStudio下载安装详细步骤
2021-04-16数组
Navagation navigation
Alimentation des animaux de compagnie basée sur stm32
JSP getting started summary
I have been promoted. How can I get along with my former colleagues at the same level?
RPC kernel details you must know (worth collecting)!!!
STM32F1与STM32CubeIDE编程实例-红外寻迹传感器驱动
高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
Golang 快速上手 (1)
How does thymeleaf get the value of the request parameter in the URL?