Label:Select CONVERT (varchar), DATEPART (YYYY,A.FSSJ) as years,--get yearCONVERT (varchar), DATEPART (MM,A.FSSJ) as months,--get monthSUM (case if b.fszt in (' 1 ', ' 2 ') then A.cfs else 0 end) as Fscgnumber,SUM (A.CFS) as FsnumberFrom T_mtn_sendrecord AINNER JOIN T_mtn_sendnote B on A.DXDM=B.DXDMGROUP by CONVERT (varchar), DATEPART (YYYY,A.FSSJ), convert (varchar), DATEPART (MM,A.FSSJ))ORDER by CONVERT (int,convert (varchar), DATEPART (YYYY,A.FSSJ)),--year converted from string to numberCONVE
Copy Code code as follows:
Select From_unixtime (pubtime, '%y-%m ') as Pubtime, COUNT (*) as CNT from articles Group by from_unixtime (Pubtime, '%y-%m ')
PHP articles are archived by Date (day) SQL
Copy Code code as follows:
Select From_unixtime (pubtime, '%y-%m-%d ') as Pubtime, COUNT (*) as CNT from articles Group by from_unixtime (Pubtime, '%y-%m -%d ')
Non-timest
Pay attention to one issue when calculating the value of a DATE caused by a month or a problem */SQL> www.2cto.com SQL> SELECT date' 2012- 30th day of last month, DATE '2017-11-30 'Toda
Last_day: returns the date of the last day of the month that contains the date parameter.Select last_day (sysdate) from dual;
Last_day (sysdate)
-------------------
2008/02/29 11:24:04
SQL> select last_day (date '2017-02-15 ') from dual;
Last_day (
In oracle, the month or part of data is obtained from the specified date. The oracle date
Obtain part of the data from the specified date:
Such as month:
Select to_CHAR (sysdate, 'mm') from dual;
Or:
Select extract (
Oracle uses ROUND and EXTRACT for date operations:
SQL>SelectTo_char (sysdate,'Yyyy/mm/dd hh24: mi: ss')FromDual;
TO_CHAR (SYSDATE, 'yyyy/MM/DDHH2
------------------------------
18:13:20
ROUND (d, [fmt]): returns a rounding date value in the fmt Format.D is the date,
format ()
F. format (stp); f. format (sTime); f. format (sqlDate); f. format (utilDate)
Java. SQL. Date sqlDate = java. SQL. Date. valueOf ("2005-12-12 ");UtilDate = new java. util. Date (sqlDate. getTime ());
Bytes ----------------------------------------------------------
(), 110)/* result: 05-06-2010 */
Select convert (varchar (12), getdate (), 113)/* result: 06 05 2010 1 */
Select convert (varchar (12), getdate (), 114)/* result: 17: 19: 44: 123 */
Generally, a date with a time value greater than or equal to the same number can be used.For example, select twrefundprice from twchangerefund where sdate
The following lists some classic instances to better understand the time and
as the last line You can create a function to handle the problem Create or Replace function sys_date return date is begin Return sysdate; End; Select To_char (sys_date, ' Hh:mi:ss ') from all_objects; 12. Get the number of hours Extract () Find the field value for the date or interval value SELECT extract (
-2010 */Select CONVERT (varchar (12), getdate (), 113)/* result: 06 05 2010 1 */Select CONVERT (varchar (12), getdate (), 114)/* result: 17: 19: 44: 123 */Generally, a date with a time value greater than or equal to the same number can be used.For example, select twRefundPrice from twChangeRefund where Sdate The following lists some classic instances to better understand the time and date operations in SQL:
Tags: SQL statement tween Postgresq a body its query char CAsWhen writing an SQL statement for a statistical query, you need to group by year, month, and day, but the fields that are required to be returned are date formats: yyyy mm month DD day. At first, my practice is to
How to calculate the period-over-period ratio of an SQL statement! The number of resumes in this month minus the number of resumes in the previous month () [number of resumes in this month]-[number of resumes in the previous month] = [number of resumes in the previous
"Number of resumes in the month"-"resumes last month" = "Number of years" ()
How is the SQL statement written?
SELECT date_format (m_adddate, '%m ') as Month,count (m_id) as Zong,date_format (m_adddate, '%Y ') as year from Job_myreceive where Date_format (m_adddate, '%Y ') =2011 GROUP by Date_format (m_adddate, '%m '
SQL Statistics this week, this month, next week, the next month SQL statement/*Table structure
Student (s#,sname,sage,ssex)--s# student number, sname student name, Sage birth date, ssex student gender
Save some data
INSERT into Student values (' ', n ' wwww.1
Convert a string in the format of "yyyy-mm-dd" to Java. SQL. Date:
Simpledateformat bartdateformat = new simpledateformat ("yyyy-mm-dd "); String datestringtoparse = "2007-7-12 "; Try { Java. util. Date = bartdateformat. parse (datestringtoparse ); Java. SQL. Date sqlda
Tags: image resolution Bubuko brackets using min ima nbsp spanDue to business needs, these two days in learning Oracle, found in Oracle's date it will give you into a very unaccustomed format, so think about how to get it into adulthood, month, day format to display, check information, look at the document, finally found a solution, in fact, the use of the To_char method. For example, in Oracle, a table in
monthSelectName,submittime fromEnterprisewhereDate_format (Submittime,'%y-%m') =date_format (now (),'%y-%m') query data that is currently 6 months from nowSelectName,submittime fromEnterprisewhereSubmittime between Date_sub (now (), interval6Month ) and now ();SelectName,submittime fromEnterprisewhereDate_format (Submittime,'%y-%m') =date_format (Date_sub (Curdate (), INTERVAL1MONTH),'%y-%m')Select* from' User 'whereDate_format (Pudate,'%y%m') = Date_format (Curdate (),'%y%m' ) ;Select* fromUse
The year, month, and day Field Values for the oracle date. The oracle Field
Address: http://yanwushu.sinaapp.com/oracle_extract_year_month_day_valu/
Previously, we used to_char (timeField, 'yyyy') to obtain the year field value in the date. This method is definitely inefficient. In order to write more standardized and reasonable
(Datetime,convert (char (8), @dt, 120) + ' 1 ')--b. The last day of the monthSELECT DATEADD (Day,-1,convert (char (8), DATEADD (month,1, @dt), 120) + ' 1 ')--4. Any day of the week on which the specified date is locatedSELECT DATEADD (Day, @number-datepart (Weekday, @dt), @dt)--5. Any day of the week on which the specified date is located--a. Sunday as the 1th d
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