Oracle  Get this week 、 This month, 、 This season, 、 The first and last days of the year

-- This week,

select trunc(sysdate, 'd') + 1 from dual;

select trunc(sysdate, 'd') + 7 from dual;

-- This month,

select trunc(sysdate, 'mm') from dual;

select last_day(trunc(sysdate)) from dual;

-- This season,

select trunc(sysdate, 'Q') from dual;

select add_months(trunc(sysdate, 'Q'), 3) - 1 from dual;

-- This year

select trunc(sysdate, 'yyyy') from dual;

select add_months(trunc(sysdate, 'yyyy'), 12) - 1 from dual;

--  Get the start time and end time of last month

select to_char(to_date(to_char(add_months(sysdate, -1), 'yyyy-mm'),'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss')

from dual;

select to_char(to_date(to_char(sysdate, 'yyyy-mm'), 'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss')

from dual;

--  Get the start time and end time of the previous day

select to_char(to_date(to_char(sysdate - 1, 'yyyy-mm-dd'), 'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss')

from dual;

select to_char(to_date(to_char(sysdate, 'yyyy-mm-dd'), 'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss')

from dual;

--  Get the start time and end time of the last hour

select to_date(to_char(sysdate, 'yyyy-mm-dd') || (to_char(sysdate, 'hh24') - 1),'yyyy-mm-dd hh24')

from dual;

select to_date(to_char(sysdate, 'yyyy-mm-dd') || (to_char(sysdate, 'hh24')),'yyyy-mm-dd hh24')

from dual;

Oracle Get this week 、 This month, 、 This season, 、 More related articles on the first and last days of the year

  1. MSSQL Gets the first and last days of the week in which the specified date is located Get the specified date to sit on the first and last day of the month

    ufn_GetWeekFirstAndEndDay     Gets the first and last days of the week in which the specified date is located ALTER FUNCTION [dbo].[ufn_GetWeekFirstAndEndDay]( ...

  2. JAVA Get this week This month, This year The first day and the last day

    /** * Date tool class */ public class DateUtils { /** * Get today * @return String * */ public static String getTod ...

  3. moment.js Get the start and end dates of this week, this month and this year

    // Get today const startDate = moment().format('YYYY-MM-DD'); const startDate = moment().format('YYYY-MM-D ...

  4. c# Get... According to the current time , This week, , This month, , This quarter , At the beginning of , end of the month , Every time period

    DateTime dt = DateTime.Now;  // current time    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") //24 hourly ...

  5. java Get the first and last days of the month or month

    Get the dates of the first and last days of a month Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Ca ...

  6. PHP Time to get this week This month, This quarter

    <?php        $week_begin = mktime(0, 0, 0,date("m"),date("d")-date("w&qu ...

  7. SQLServer Database SQL Server Get this week , This month, , This year, etc

    This article mainly introduces SQLServer Database SQL Server Get this week , This month, , This year, etc , Through the specific content to show you , I hope to learn from you SQLServer Databases help . datediff(we ...

  8. c# obtain This week, 、 This month, 、 This quarter 、 This year Start time or end time of

    #region obtain This week, . This month, . This quarter . This year Start time or end time of /// <summary> /// Get the end time /// </summary> /// <param ...

  9. SQL Server Get this week , This month, , This year, etc

    datediff(week,zy_time,getdate())=0 // Check this week datediff(month,zy_time,getdate())=0 // Inquire about this month This season, :select * fro ...

Random recommendation

  1. 【BFS】POJ 2251

    POJ 2251 Dungeon Master The question : There's a map , The three dimensional , The direction is up and down , about , Before and after . Ask you the minimum number of steps from the starting point to the exit . Ideas : The three-dimensional BFS, Just add one more set of states , You need to be careful ( If I'm not careful, I find half of them ...

  2. Loss function (Loss Function) -1

    http://www.ics.uci.edu/~dramanan/teaching/ics273a_winter08/lectures/lecture14.pdf Loss Function Loss function ...

  3. $.extend abc

    console.log(jQuery.extend(this,{'a':'b'},{'c':'d'}));console.log(this.a)var tt = jQuery.extend({},{' ...

  4. The finger of the sword Offer: Interview questions 18—— The substructure of a tree (java Realization )

    Problem description : Input two binary trees A and B, Judge B Is it right? A Substructure of . The definition of binary tree node is as follows : public class TreeNode { int val = 0; TreeNode left = null; ...

  5. COJ WZJ Data structure of ( Negative 18 )splay_tree Heaven of

    WZJ Data structure of ( Negative 18 ) Difficulty level :E: Run time limit :100000ms: Operating space limitation :700KB: Code length limit :2000000B Test description For the previous example : Input Enter the... Of the file 1 The row contains two numbers N ...

  6. js Convert the age according to the date of birth

    function age_Conversion(date) { debugger var age = ''; var str = date.replace(/ year | month /g, "-") ...

  7. CDlinux Make U Disk boot disk , Build your own pocket system

    Tools : 1.8G Or more U Take one : 2.CDlinux0.9.7.1 Image file , Note that other versions don't always work ( Portal http://pan.baidu.com/s/1o7P6Gu2): 3.UltraISO or U ...

  8. Chinese code examples of Electron Desktop application development experience

    Reference resources : Build your first Electron application First, run the following to create package.json: $ npm init After removing some irrelevant items, the content is as follows : { "name": &quo ...

  9. HADOOP HA Step on the pit - org.apache.hadoop.hdfs.qjournal.protocol.JournalNotFormattedException: Journal Storage Directory /mnt/data1/hadoop/dfs/journal/hdfscluster not formatted

    Report errors : stay journalnode Of log in : org.apache.hadoop.hdfs.qjournal.protocol.JournalNotFormattedException: Journal ...

  10. sklearn Module function introduction

    One .sklearn.metrics.accuracy_score This package can help us count the same number of elements in the same position in two lists , Like what we predicted label And the real label What's the gap , What's the accuracy of the prediction , ...