SQL Scalar function-----Date function day (), month (), year ()

Source: Internet
Author: User
Tags getdate scalar

Select Day (createtime) from Life_unite_product--the days value of the Take time field

Select Month (createtime) from Life_unite_product--take the month value of the Time field

Select year (createtime) from Life_unite_product--the yearly value of the Fetch time field

Select DATEPART (yy,createtime) from Life_unite_product--take the year value of the Time field

Select DATEPART (qq,createtime) from Life_unite_product--take the quarter value of the Time field

Select DATEPART (mm,createtime) from Life_unite_product--take the month value of the Time field

Select DATEPART (dy,createtime) from Life_unite_product--Take time field is the day ordinal of that year

Select DATEPART (dd,createtime) from Life_unite_product--the day value of the Fetch time field

Select DATEPART (wk,createtime) from Life_unite_product--Take the Time field is the first week of that year

Select DATEPART (dw,createtime) from Life_unite_product--Take the Time field is the first weekday of the Week of that year (working days are calculated from Sunday)

Select DATEPART (hh,createtime) from Life_unite_product--the time-out value of the Fetch field

Select DATEPART (mi,createtime) from Life_unite_product--Take the minute value of the Time field

Select DATEPART (ss,createtime) from Life_unite_product--takes the seconds value of the Time field

Select DATEPART (ms,createtime) from Life_unite_product--take the millisecond value of the Time field

Select DATEADD (yy,-1,createtime) from life_unite_product----fetch Time field (year is reduced by 1)

Select DATEADD (mm,3,createtime) from life_unite_product----fetch Time field (month is added 3)

Select DATEADD (dd,1,createtime) from life_unite_product----fetch time field (Day added 1)

Select DATEDIFF (Yy,createtime,getdate ()) from life_unite_product--year difference from current date

Select DATEDIFF (Mm,createtime,getdate ()) from Life_unite_product--The month difference from the current date

Select DATEDIFF (Dd,createtime,getdate ()) from Life_unite_product--the difference in the number of days from the current date

Select DATEDIFF (Mi,createtime,getdate ()) from Life_unite_product--the difference in minutes from the current date

Select Datename (yy,createtime) from Life_unite_product--take the year value of the Time field

Select Datename (mm,createtime) from Life_unite_product--take the month value of the Time field

Select Datename (dd,createtime) from Life_unite_product--the day value of the Fetch time field

Select GETDATE ()--Take the current time


Source: >  

From for notes (Wiz)

SQL Scalar function-----Date function day (), month (), year ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.