Round and Trunc with dates

Can I get the examples for round and Trunc with dates?

Like this? ;)

with
test_date as
(select to_date(:a_date,'yyyymmddhh24miss') the_date
          from dual
)
select the_date,'CC' pattern,round(the_date,'CC') rounded,trunc(the_date,'CC') truncated from test date
union all
select the_date,'SCC' pattern,round(the_date,'SCC') rounded,trunc(the_date,'SCC') truncated from test date
union all
select the_date,'SYYYY' pattern,round(the_date,'SYYYY') rounded,trunc(the_date,'SYYYY') truncated from test date
union all
select the_date,'YYYY' pattern,round(the_date,'YYYY') rounded,trunc(the_date,'YYYY') truncated from test date
union all
select the_date,'YEAR' pattern,round(the_date,'YEAR') rounded,trunc(the_date,'YEAR') truncated from test date
union all
select the_date,'SYEAR' pattern,round(the_date,'SYEAR') rounded,trunc(the_date,'SYEAR') truncated from test date
union all
select the_date,'YYY' pattern,round(the_date,'YYY') rounded,trunc(the_date,'YYY') truncated from test date
union all
select the_date,'YY' pattern,round(the_date,'YY') rounded,trunc(the_date,'YY') truncated from test date
union all
select the_date,'Y' pattern,round(the_date,'Y') rounded,trunc(the_date,'Y') truncated from test date
union all
select the_date,'IYYY' pattern,round(the_date,'IYYY') rounded,trunc(the_date,'IYYY') truncated from test date
union all
select the_date,'IYY' pattern,round(the_date,'IYY') rounded,trunc(the_date,'IYY') truncated from test date
union all
select the_date,'IY' pattern,round(the_date,'IY') rounded,trunc(the_date,'IY') truncated from test date
union all
select the_date,'I' pattern,round(the_date,'I') rounded,trunc(the_date,'I') truncated from test date
union all
select the_date,'Q' pattern,round(the_date,'Q') rounded,trunc(the_date,'Q') truncated from test date
union all
select the_date,'MONTH' pattern,round(the_date,'MONTH') rounded,trunc(the_date,'MONTH') truncated from test date
union all
select the_date,'MON' pattern,round(the_date,'MON') rounded,trunc(the_date,'MON') truncated from test date
union all
select the_date,'MM' pattern,round(the_date,'MM') rounded,trunc(the_date,'MM') truncated from test date
union all
select the_date,'RM' pattern,round(the_date,'RM') rounded,trunc(the_date,'RM') truncated from test date
union all
select the_date,'WW' pattern,round(the_date,'WW') rounded,trunc(the_date,'WW') truncated from test date
union all
select the_date,'IW' pattern,round(the_date,'IW') rounded,trunc(the_date,'IW') truncated from test date
union all
select the_date,'W' pattern,round(the_date,'W') rounded,trunc(the_date,'W') truncated from test date
union all
select the_date,'DDD' pattern,round(the_date,'DDD') rounded,trunc(the_date,'DDD') truncated from test date
union all
select the_date,'DD' pattern,round(the_date,'DD') rounded,trunc(the_date,'DD') truncated from test date
union all
select the_date,'J' pattern,round(the_date,'J') rounded,trunc(the_date,'J') truncated from test date
union all
select the_date,'DAY' pattern,round(the_date,'DAY') rounded,trunc(the_date,'DAY') truncated from test date
union all
select the_date,'DY' pattern,round(the_date,'DY') rounded,trunc(the_date,'DY') truncated from test date
union all
select the_date,'D' pattern,round(the_date,'D') rounded,trunc(the_date,'D') truncated from test date
union all
select the_date,'HH' pattern,round(the_date,'HH') rounded,trunc(the_date,'HH') truncated from test date
union all
select the_date,'HH12' pattern,round(the_date,'HH12') rounded,trunc(the_date,'HH12') truncated from test date
union all
select the_date,'HH24' pattern,round(the_date,'HH24') rounded,trunc(the_date,'HH24') truncated from test date
union all
select the_date,'MI' pattern,round(the_date,'MI') rounded,trunc(the_date,'MI') truncated from test date

Concerning

Etbin

Tags: Database

Similar Questions

  • Diference between consolidation and consolidate with data

    I would like to get said about the differences between the "Consolidate" and option "Consolidate all" in HFM while performing a grouping.

    Please see next post

    Difference between "Consolidate" and "consolidate all"in HFM.

    Varun

  • retriving records with date and time stamps

    I need to get all records that have been updated between 08:36:06 and 08:36:09 12/15/2009

    I use this application it gives me the numbers on the right (I think) because this condition GURMAIL_CPLN_CODE = 'UGAP', I want something more
    using the stamp date and time with dates
    12/15/2009 08:36:06 AM
    12/15/2009 08:36:07 AM
    12/15/2009 08:36:08 AM
    12/15/2009 08:36:09 AM
    select * from GURMAIL
    where 
    PERMAIL_CPLN_CODE = 'UGAP'
    AND TO_CHAR(PERMAIL_ACTIVITY_DATE,'MM/DD/YYYYHH24:MI:SS AM') >= '12/15/2009 08:36%'
    Thank you

    face-> Office (while exclaiming in despair "¿Dang, now how could I miss that?")

    Yes, Max, you're right, thanks for being there!
    When I never learn never to post a reply, unless I ran the code me first? ;)
    In any case: bed here now, ciao!

  • Combine the size and attributes with application Dates

    Hello, I'm trying to combine data from two tables (DIMENSION and ATTRIBUTES) below and load the data corresponding to the OUTPUT.

    Can anyone share idea on how I can combine the two? (attribute table has no ID and has only COUNTRY & TYPE to join DIMENSION)

    Version Oracle 11g: (11.2.0.2)


    DATA_SAMPLE.PNG

    CREATE TABLE DIM (ID VARCHAR2 (10), NAME VARCHAR2 (20), TYPE VARCHAR2 (20), COUNTRY VARCHAR2 (2), EFF_DT DATE, DATE END_DT);

    CREATE THE TABLE ATTRIBUTES (TYPE VARCHAR2 (20), COUNTRY VARCHAR2 (2), CHAR (1) OF THE CLASS, EFF_DT DATE, DATE END_DT);

    INSERT INTO VALUES('1','ABC','A','US',TO_DATE('30-SEP-2013','DD-MON-YYYY'),TO_DATE('31-DEC-2099','DD-MON-YYYY')) DIM;

    INSERT INTO VALUES('1','ABC','A','CA',TO_DATE('30-SEP-2013','DD-MON-YYYY'),TO_DATE('31-DEC-2099','DD-MON-YYYY')) DIM;

    INSERT IN DIM values('2','XYZ','B','US',TO_DATE('3-FEB-2014','DD-MON-YYYY'),TO_DATE('31-DEC-2099','DD-MON-YYYY'));

    INSERT IN the values('A','US','C',TO_DATE('1-JAN-2014','DD-MON-YYYY'),TO_DATE('28-SEP-2014','DD-MON-YYYY ATTRIBUTES '));

    INSERT IN the values('A','US','C',TO_DATE('29-SEP-2014','DD-MON-YYYY'),TO_DATE('31-DEC-2099','DD-MON-YYYY ATTRIBUTES '));

    INSERT IN the values('A','CA','E',TO_DATE('1-JAN-2014','DD-MON-YYYY'),TO_DATE('28-OCT-2014','DD-MON-YYYY ATTRIBUTES '));

    INSERT IN the values('A','CA','E',TO_DATE('29-OCT-2014','DD-MON-YYYY'),TO_DATE('31-DEC-2099','DD-MON-YYYY ATTRIBUTES '));

    Thank you.

    Maybe let separate everything first delete duplicates

    with

    Sun did

    (select id '1', the name of 'ABC', 'A' type, 'US' country, to_date('30-SEP-2013','DD-MON-YYYY') eff_dt, to_date('31-DEC-2099','DD-MON-YYYY') end_dt Union double all the)

    Select '1','ABC','A','CA',to_date('30-SEP-2013','DD-MON-YYYY'),to_date('31-DEC-2099','DD-MON-YYYY') of all the double union

    Select '2','XYZ','B','US',to_date('3-FEB-2014','DD-MON-YYYY'),to_date('31-DEC-2099','DD-MON-YYYY') of the double

    ),

    attributes such as

    (select 'A' type, countries 'US', 'C' class, to_date('1-JAN-2014','DD-MON-YYYY') eff_dt, to_date('28-SEP-2014','DD-MON-YYYY') end_dt Union double all the)

    Select 'A','US','C',to_date('29-SEP-2014','DD-MON-YYYY'),to_date('31-DEC-2099','DD-MON-YYYY') of all the double union

    Select 'A','CA','E',to_date('1-JAN-2014','DD-MON-YYYY'),to_date('28-OCT-2014','DD-MON-YYYY') of all the double union

    Select 'A','CA','E',to_date('29-OCT-2014','DD-MON-YYYY'),to_date('31-DEC-2099','DD-MON-YYYY') of the double

    )

    SELECT id, name, type, country, class, eff_dt, end_dt

    NVL (lead (eff_dt) over (partition BY id, type, order of eff_dt countries) - 1, end_dt) end_dt_new

    from (select distinct id, name, coalesce(type_d,type_a) type, country, case when x = 'a' then class end class, eff_dt,)

    -case when end_dt = date ' 2099-12-31' then add_months (trunc (eff_dt, 'yyyy'), 12)-1 else end_dt end end_dt

    from (select d.id, d.name, d.typ subscription_type, a.typ type_a, d.country, a.class,)

    d.eff_dt d_eff_dt, d.end_dt d_end_dt, a.eff_dt a_eff_dt, a.end_dt a_end_dt

    Dim d

    full outer join

    attributes one

    We d.country = a.country

    and d.typ = a.typ

    )

    UNPIVOT ((eff_dt,end_dt) for x in ((d_eff_dt,d_end_dt) as ' of,(a_eff_dt,a_end_dt) like 'a'))

    )

    order by 1,2,3,4,6

    ID NAME TYP COUNTRY CLASS EFF_DT END_DT END_DT_NEW
    1 ABC A CA - 30/09/2013 31/12/2013 31/12/2013
    1 ABC A CA E 01/01/2014 28/10/2014 28/10/2014
    1 ABC A CA E 29/10/2014 31/12/2014 31/12/2014
    1 ABC A WE - 30/09/2013 31/12/2013 31/12/2013
    1 ABC A WE C 01/01/2014 28/09/2014 28/09/2014
    1 ABC A WE C 29/09/2014 31/12/2014 31/12/2014
    2 XYZ B WE - 03/02/2014 31/12/2014 31/12/2014

    Concerning

    Etbin

  • I created a custom and registered with a specific name date format. However, when I open a new worksheet, my saved format does not display in the menu drop-down? Am hoping that I don't need to create the same format for each new sheet?

    I created a custom and registered with a specific name date format. However, when I open a new worksheet, my saved format does not appear in the menu drop-down? Am hoping that I don't need to create the same format for each new sheet?

    You must save the spreadsheet containing the new date as a model format and use this custom template for each new spreadsheet where you want that this date format personalized at your disposal.

  • I recently updated my iPhone to iOS 9.3 6s and now my data and wifi are in place. Now I can't open the apps and send messages with data and barely on the wifi. I've tried everything, and it still does not work.

    I updated my iPhone to iOS 9.3 6s today and now my data and wifi are in place. Whenever I try to open an app or send text messages with data it does not at all. And with wifi, it just works. I tried just like turn roaming off and off and other lte but nothing seems to work at all. Can someone please?

    I have this same problem too, it really gets me upset

  • I just replaced my MB Pro with a MB Air. Air has less memory and will not support a full restore of files and the saved data. How to do a partial restore

    I just replaced my MB Pro with a MB Air. Air has less memory and will not support a full restore of files and the saved data. How to do a partial restore

    Do you still have the MBP? If so you can manually copy and paste the files you need.

    If you do not have the pro more, you need to buy a USB key and plug it into the MBA... use it as a target. Once you have a system file of the previous laptop again, you have to manually choose what to copy across.

  • my Apple Watch does not record the data of my activity on my iPhone. The application of the activity is implemented on my watch and twinned with phone and not yet to record data.

    my Apple Watch does not record the data of my activity on my iPhone. The application of the activity is implemented on my watch and twinned with phone and not yet to record data.

    HI - try the following steps:

    On your iPhone close application of activity and also, if it runs in the background, the health app (you can close open apps, including the app shows):

    -Double-click the Home button, and then drag upward on each of the app previews to close.

    It can help to restart your iPhone and your watch. Turn on both devices off the power together first, and then restart your iPhone before restarting your watch:

    -To switch off your watch: press and hold the button side until you see the cursor off the power; slide it to turn off;

    -To switch on: press and hold the side button until you see the Apple logo.

    If this does not resolve the problem, try next disconnect and rematching of your watch:

    -L'app shows on your iPhone shows backups automatically, including a new when the unpairing via the application.

    -Choose to restore the watch (backup restore) when provided the opportunity during the whole.

    -Most of the data and settings will be restored, with a few exceptions (for example cards Pay Apple, access code).

    - Pairing your Apple Watch and Support Apple - iPhone

    - Set up your Apple Watch - Apple Support

  • A few days, I bought a mac mini which I transferred the data and programs with time machine: programs have been updated except for iMovie, and now it seems that I have to pay for the update: possible? What I am doing wrong?

    A few days ago, I bought a mac mini and I transferred all my data and programs with time machine: all programs have been updated but iMovie (7.1.4)... However, it seems that, to update to the latest version, I have to pay to download on Appstore: is it possible? what I am doing wrong?

    If it were a new mac mini, you need already installed 10.1 iMovie.  Otherwise, but you already have iMovie 9 registered version to your Apple ID, you can upgrade to version 10 for free, but if (as it appears) is an earlier version then you have to buy version 10.

    Geoff.

  • Bad drift with USB-6259 devices and acquisition of data PCI-6259

    We have both a USB-6259 and PCI-6259 installed on a single computer, linked to a SBC-68, with Matlab and Toolbox of data Acquisiution.

    For the purposes of test base, I wrote a script that generates a sinusoidal signal output based MATLAB, for a single DAC output.  I wired this single DAC output to two channels of ADC of entry.  For each sample output DAC, the script also takes a sample entry of ADC on each channel.

    --> Ideally, if everything works correctly, after you run the script, I see two channels of input ADC vector.  Tracing of each channel should give me a nice sine wave in Matlab.

    --> When I made trace data, here's what I get (see attachment).

    -->, I looked at the DAC output with an oscilloscope, and the DC offset is very close to 0 (this indicates to me that the part of output DAC works very well).

    Why is there this negative DC drift on two entries?

    Forgive my lack of knowledge - I know the difference between the DIFF and CSR connections, but I don't know where is the 'setting' for DIFF/CSR (what is a button/switch on the USB-6259 case?  Is it a software control in the code?)

  • Make XY graph from the string with date and time data

    1 all sorry for my English.

    I have files with data. In this array of strings, I have 2 columns with date and time. I want to show these data to the XY Chart with time and date on some of the DBL and X on Y.

    I tried to do it by myself, but cannot add to time on X axis.

    Hi olderon,

    you date string is something like "30.01.2014" but looking for "%d//%m %y. Spot the problem?

  • How to connect a portable laptop Windows 8 with Windows 7 computer via Ethernet cable and transfer the data directly?

    I have a laptop Windows 8 . I want to connect to a new round of windows 7 and transfer the data at least 8 MB/s.

    Please send me the procedure to follow. I don't want to share Internet, but want to transfer data.

    You can do this, but you need a special type of Ethernet cable called a crossover cable.  This means the son in the swap position cables so that "send" and "receive" the computer two plugs can communicate.

    Learn more here: http://windows.microsoft.com/en-us/windows/connect-two-computers-crossover-cable#1TC=windows-7

  • my system does not start upwards - don't stop progression blue bar that goes round and round. I can boot into safe mode and safe mode with networking mode.

    my system does not start upwards - don't stop progression blue bar that goes round and round.  I can boot into safe mode and safe mode with networking mode.

    Hello

    As you are able to boot to the desktop in Mode safe, it means that the third-party application prevents the computer from starting in normal mode. To check you can configure the computer to clean start State and then try to boot into normal mode and check what is happening. To set up its own start-up follow the link below.

    http://support.Microsoft.com/kb/310353

    If the problem does not continues when the computer is in the clean start State follow the steps listed to identify which application is causing the problem.

    Note: When you are finished troubleshooting, follow step 7 article to start on normal startup.

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • HI everyone, I paid almost 10 days ago, my supcripcion to plan for all the app elements, and after u date of my latest plan, any program is runing, always appear, your time taking, is late, please by the app with my adobe ID works correctly?

    HI everyone, I paid almost 10 days ago, my supcripcion to plan for all the app elements, and after u date of my latest plan, any program is runing, always appear, your time taking, is late, please by the app with my adobe ID works correctly?

    Photoshop Elements and Premiere Elements are NOT part of the cloud... you buy a serial number, not a subscription, and you enter the serial number during installation

    If you don't want to say things, read below

    Your subscription to cloud shows correctly on your account page?

    If you have more than one email, you will be sure that you use the right Adobe ID?

    https://www.adobe.com/account.html for subscriptions on your page from Adobe

    .

    If Yes

    Some general information for a subscription of cloud

    Cloud programs don't use serial... numbers you, connect you to your cloud account paying to download & install & activate... you may need to sign out of the cloud and restart your computer and log into the cloud for things to work

    Sign out of your account of cloud... Restart your computer... Connect to your paid account of cloud

    -Connect using http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html

    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html

    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html

    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html

    -ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp

    -http://helpx.adobe.com/creative-cloud/kb/license-this-software.html

    .

    If no

    This is an open forum, Adobe support... you need Adobe personnel to help

    Adobe contact information - http://helpx.adobe.com/contact.html

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    -Select your product and what you need help with

    -Click on the blue box "still need help? Contact us. "

  • What I see if I work with Microsoft and exchange of data on the creative clouds with people working on Apple?

    What I see if I work with Microsoft and exchange of data on the creative clouds with people working on Apple?

    That all depends on what you want to share

    The data files that are "industry standard" such as the JPG images are the same on both platforms

    Files that are specific to the platform, such as video files on a Mac or Windows, AVI video files MOV will either require conversion or additional software (to open a MOV file with a Windows program, you must have installed Apple Quicktime for Windows)

    In addition to this, the files that are specific to Adobe... such as the InDesign files... are not always compatible because of new features in newer versions, like a Premiere Pro video project file created in the 2015 version cannot open in 2014 version

    If you have problems with files and specific programs, you should ask for help in the forums for these programs

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll

Maybe you are looking for