How to convert sysdate to the format dd-mon-yyyy

how to convert sysdate to the format dd-mon-yyyy

<how to convert sysdate to the format dd-mon-yyyy>
This question is better answered by thinking about about how Oracle dates work. SYSDATE is a pseudocolumn (function without any arguments) that returns a date value: it already is a date. Oracle date values are stored not as we see them, say 'DD-MON-YY', but as a series of bytes with the different date components from the millennium down to the second. We NEVER see dates as they are stored but use the formats for automatic conversion.
To display a date the way you want use TO_CHAR() with an edit mask or as others suggested change your NLS_DATE_FORMAT (thought I advise against this as most systems use DD-MON-YY and porting queries from other systems or even OTN can easily break). To change a converted string back to a date use TO_DATE() with an edit mask.

Similar Messages

  • Sysdate - how to convert into a certain format

    Hi,
    I am trying to use sysdate as a default parameter in one of my reports and getting an error message (ORA-01843: not a valid month)...
    my sysdate is coming up in the following format (DD-MMM-YY) and is giving an error message... but when I tried the date manually in following format (MM/DD/YYYY) it worked...
    may I know how to convert sysdate into the following format MM/DD/YYYY
    thanks in advance

    my sysdate is coming up in the following format (DD-MMM-YY)
    There is no "MMM" format model. And how often does it have to be explained that 2-digit year formats are just wrong?
    Suggest you post the query or expression that is causing the error. Generally there is no reason to convert <tt>sysdate</tt> away from a <tt>DATE</tt> type for anything other than display purposes. It is more likely that the error is due to an implicit conversion of another value to <tt>DATE</tt> using a non-default or incorrect format mask.
    Also post the result of running
    select * from v$nls_parametersin the SQL Workshop.
    Edited by: fac586 on 13-Jun-2011 18:00

  • How to convert milliseconds to date format in sql query

    Hi All,
    The following code is in java.     
    String yourmilliseconds = "1316673707162";**
    Date resultdate = new Date(Long.parseLong(yourmilliseconds));
    could you plese tell me how to convert milliseconds into date format in query and comparing with another date like(sysdate-3)

    Hello,
    http://stackoverflow.com/questions/3820179/convert-epoch-to-date-in-sqlplus-oracle
    Regards

  • How to convert date to ccyymm format

    Hi,
    How to convert date to ccyymm format.
    Thanks

    dadivela wrote:
    Re: How to convert date from ccyymm format to mmddyyI didn't inderstand. Date doesn't have any format. If you have a string in CCYYMM format, you would have to extract the YYMM from the string.
    SQL> SELECT   SYSDATE,
      2           TO_CHAR (SYSDATE, 'ccyymm') Date_Fm,
      3           SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3) YYMM
      4    FROM   DUAL
      5  /
    SYSDATE   DATE_F YYMM
    08-JUN-09 210906 0906You can use this string to convert it to date. Note that since DD part of your date was not their in the resultan string, the converted date will fall back to first of the month specified.
    SQL> SELECT   SYSDATE,
      2           TO_CHAR (SYSDATE, 'ccyymm') Date_Fm,
      3           SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3) YYMM,
      4           TO_DATE (SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3), 'YYMM') conv_Dat
    e
      5    FROM   DUAL
      6  /
    SYSDATE   DATE_F YYMM             CONV_DATE
    08-JUN-09 210906 0906             01-JUN-09
    SQL>Then convert the date into the required format using TO_CHAR Function
    SQL> SELECT   SYSDATE,
      2           TO_CHAR (SYSDATE, 'ccyymm') Date_Fm,
      3           SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3) YYMM,
      4           TO_DATE (SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3),
      5                   'YYMM') conv_Date,
      6           TO_CHAR(TO_DATE(SUBSTR(TO_CHAR (SYSDATE, 'ccyymm'),3),
      7                   'YYMM'), 'MMDDYY') New_Format
      8    FROM   DUAL
      9  /
    SYSDATE   DATE_F YYMM             CONV_DATE NEW_FO
    08-JUN-09 210906 0906             01-JUN-09 060109
    SQL>Hope this helps.
    Regarads,
    Jo

  • Need to convert  Date from calendar to String in the format dd-mom-yyyy

    Need to convert Date from calendar to String in the format dd-mom-yyyy+..
    This is absolutely necessary... any help plz..
    Rgds
    Arwinder

    Look up the SimpleDateFormat class: http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    Arwinder wrote:
    This is absolutely necessary... any help plz..For you maybe, not others. Please refrain from trying to urge others to answer your queries. They'll do it at their own pace ( if at all ).
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • How to convert exponent to number format

    Hi,
    how to convert exponent to number format.My column is in number and the data is in exponent format .for example  data is 2.44705130197009E18 .when i do field name haveing this data like
    select * from table name where filed name =2.44705130197009E18 ,field name  is of number (20) data type .but i am not getting any data fectched .
    your advice is at most appriciated .
    Regards,
    Suja

    Example of what I was saying...
    SQL> create table myexp (name number);
    Table created.
    SQL> insert into myexp values (2447051301970090001);
    1 row created.
    SQL> select name from myexp;
          NAME
    2.4471E+18
    SQL> col name format 9999999999999999999999999999999999999
    SQL> select name from myexp;
                                      NAME
                       2447051301970090001
    SQL>
    The number you are seeing as an exponent is not just the number that is stored with lots of 0's on it, there's other information you are missing, so you need to change your format to see the true value.

  • How to convert VOB to other formats?

    As a professional VOB converter, Emicsoft VOB Converter is currently one of the best and most easy-to-use converter which can convert VOB videos to most popular video and audio formats with fast conversion speed and perfect sound & picture quality, such as VOB to MP3, VOB to M4A, VOB to WAV, VOB to AAC, VOB to AC3; VOB to DVD Video(*.vob), DVD Video-NTSC(*.vob), MPEG-1 Video(*.mpg), MPEG-2 Video (*.mpg), etc.
    Emicsoft VOB Converter can not only play the role as a converter, moreover, it can also be used as a powerful editor, which provides a lot of professional video editing functions, such as merging several videos into one file, cutting any clip of your video, cropping the video size, editing video effect and so on. You can also set output profile parameters including resolution, bitrate, frame rate, aspect ratio to get the best video quality and video size.
    How to convert VOB to other formats?
    1. Launch the software and click "Add File" button to import files into the software. You can watch them on the preview screen.
    2. Edit the added movie by clicking "Effect" "Trim" or "Crop" button which can help you create unique videos easily.
    3. Select output in Profile option. Here all popular formats and mobile devices are supported. Then make sure the destination folder.
    4. Click "Start" button and the program will automatically start conversion.
    Emicsoft VOB Converter is so outstanding with powerful converting functions and editing functions that you can enjoy it as a good helper.
    Emicsoft M2TS Converter is currently considered as one of the most professional conversion tool, due to its powerful function, user-friendly interface and easy-to-use operation design. It can achieve any video formats from M2TS to MPEG1, MPEG2, SWF, FLV, DivX, XviD, QuickTime Video, DV, AVI, MP4, WMV and HD videos, so as to make it available to sync M2TS to iPod, iPhone, PSP, BlackBerry and other mobile devices.
    Emicsoft Tod Converter is an easy-to-use HD Video conversion tool which helps you convert HD video Tod to other formats like FLV, SWF, AVI, M4V, MOV, DivX, XviD, MPEG-1, MPEG-2, VOB, MP4, M4V, RM, RMVB, WMV, MKV, AVI, 3GP, HD video with high output quality and fast converting speed. Apart from as a HD video converter, it is also a audio converter and extractor, the Emicsoft Tod Converter can aid you to extract music from Tod video such as WAV, OGG, WMA, MP3 with good sound quality.
    More softwares may help you:
    Emicsoft Video Converter
    Emicsoft FLV Converter
    Emicsoft MTS Converter

    Open the General section of the iTunes preferences, press the Import Settings button, change the default encoder to MP3, right-click the songs, and convert them to MP3. Protected content from the iTunes Store can't be used on an MP3 player.
    (37170)

  • How can I find out the format of a DVD?

    I have DVDs which are not labelled with the format ... DVD-R. DVD+R etc.
    How can I find out the format?

    Interesting ... but I need a magnifying glass to read some of the icons ... is there some other information where this information is kept in text form?

  • How to convert 12 hour time format to 24 hour time format ?

    Hi,
    How to convert 12 hour time format to 24 hour time format is there any FM if not, please suggest me how to convert .
    regards,
    rakesh

    Hi,
    Have you tried function module HRVE_CONVERT_TIME
    Input parameters will be like
    TYPE_TIME                       B
    INPUT_TIME                      01:00:00
    INPUT_AM_PM                  PM
    Output
    OUTPUT_TIME                     13:00:00
    Regards

  • How to convert date from ccyymm format to mmddyy

    hi,
    How to convert date from ccyymm format to mmddyy

    Please don't multipost. This question has been answered in your first post.
    How to convert date to ccyymm format
    Regards,
    Jo

  • Convert varchar2 field into date formatted: DD-MON-YYYY

    Thanks in advance for anyone's help on this matter as I know it takes your time and expertise. I am pretty new to SQL but learning my way through it just have an issue with a text to date field conversion. It is an Oracle 10g database and I am writing in SQL. There is a field called Demand which is formatted in varchar2 format of ddmmyy. There is also a field that is formatted as a date called Payment which is formatted as DD-MON-YYYY.
    Essentially I need to do a simple Payment >= Demand, however as you can see that is some issue with that being a varchar2 field. Does anyone know if it is possible to do that type of expression against those two fields. Was thinking about possibly converting the varchar2 to a date but not sure how to get to that DD-MON-YYYY format.
    Also there are situations where this Demand field will often times be null as it would have never recieved any outbound correspondence in the past and would not have a date at all.
    Thanks
    Edited by: user10860766 on Aug 18, 2009 8:14 AM
    Edited by: user10860766 on Aug 18, 2009 8:19 AM

    Hi,
    It's hard to detect bad dates in pure SQL, especially if you need to be precise about when February 29 is valid.
    It's easy with a user-define function, like the one in [this thread|http://forums.oracle.com/forums/thread.jspa?messageID=3669932&#3669932].
    Edited by: Frank Kulash on Aug 18, 2009 3:50 PM
    To create a stand-alone function:
    CREATE OR REPLACE FUNCTION     to_dt
    (     in_txt          IN     VARCHAR2                    -- to be converted
    ,     in_fmt_txt     IN     VARCHAR2     DEFAULT     'DD-MON-YYYY'     -- optional format
    ,     in_err_dt     IN     DATE          DEFAULT     NULL
    RETURN DATE
    DETERMINISTIC
    AS
    BEGIN
         -- Try to convert in_txt to a DATE.  If it works, fine.
         RETURN     TO_DATE (in_txt, in_fmt_txt);
    EXCEPTION     -- If TO_DATE caused an error, then this is not a valid DATE: return in_err_dt
         WHEN OTHERS
         THEN
              RETURN in_err_dt;
    END     to_dt
    /To use it:
    SELECT  primary_key  -- and/or other columns to identify the row
    ,       demand
    FROM    table_x
    WHERE   demand          IS NOT NULL
    AND     to_dt ( demand
               , 'DDMMYY'
               )          IS NULL;

  • Validating a text field that has date in the format mm/dd/yyyy

    How can I validate a text field such that it should be in the format mm/dd/yyyy and it should not be greater that a particular date.
    for example the date I enter should not be greater than 01/01/2007

    What you can do is use the SimpleDateFormat class to try and parse the text date into a Date object like this:
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    Date mydate = sdf.parse(textdate);if that fails than the date has the wrong format (you'll get a ParseException if I'm not mistaken).
    The next step is to create a Date for 1/1/2007 and then do a date compare between your two dates. You can create a date yourself using the Calendar class.

  • Date should be in this format DD-MON-YYYY  HH:MI:SS

    Hi All,
    I am having a column date data type ,in that i am using SYSDATE and formating as DD-MON-YYYY HH:MI:SS but result iam not getting in this format,any one please help me regarding this..
    Thanks in Advance..
    Edited by: 30021986 on Oct 14, 2012 1:38 PM
    Edited by: 30021986 on Oct 14, 2012 3:38 PM

    there is a misunderstanding.
    Your database column is in a DATE type. This is a type, and thanks to this type, you can DISPLAY the date in various ways in a query editor (toad, sql developer...).
    I mean, there is no various physical Date type columns, but only one called "date".
    If you want to display this date in the way "DD-MON-YYYY HH:MI:SS", then convert it into "CHAR" (or VARCHAR) type with the function TO_CHAR (in oracle).
    Example : to_char(sysdate, 'DD-MMMM-YYYY HH24:MI:SS").
    But the result will be an alphanumeric type. You won't be able to do further operation on date, like adding a day for instance.
    That's why you should keep the date format in the column of your database table, but convert it in your queries.
    If you really need to have this specified format, then use the char or varchar type in your database table.

  • Need regular expression for oracle date format 'DD-MON-YYYY'

    Hi,
    Can anybody tell me the regular expression to validate date in 'DD-MON-YYYY'.
    My concept is i have a table with just two columns item_name and item_date
    Both fields are varchar2 and i want to fetch those records from this table which have valid date format('DD-MON-YYYY').

    If it must be a regexp, this is a starter for you, note it carries the caveats mentioned by both posters above and in the linked thread
    mkr02@ORA11GMK> with data as (select '10-jan-2012' dt from dual
      2  union all select '10-111-2012' from dual
      3  union all select 'mm-jan-2012' from dual
      4  union all select '10-jan-12' from dual)
      5  select
      6  dt,
      7  case when regexp_like(dt,'[[:digit:]]{2}-[[:alpha:]]{3}-[[:digit:]]{4}','i') then 1 else 0 end chk
      8  from data
      9  /
    DT                 CHK
    10-jan-2012          1
    10-111-2012          0
    mm-jan-2012          0
    10-jan-12            0It will not validate content, only string format.
    And to emphasis the points made in the linked thread - dates in text columns is poor design. Always.

  • How to Convert Varchar2 to Date format(Timestamp)

    I have a date saved in varchar2 column.
    how can I convert the values into date(including Time stamp), so I can use the date to compare data.
    Ex: I have the value '20-03-2007 05:31:29', but this value is saved as varchar2.
    how can I take from this value the date '20-03-2007 05:31:29' as date format because later i need that date completely to add days, hours and minutes?

    SQL> create table dd (a varchar2(15));
    Table created.
    SQL>
    SQL>
    SQL> insert into dd values (sysdate);
    1 row created.
    SQL> insert into dd values (sysdate);
    1 row created.
    SQL> insert into dd values (sysdate);
    1 row created.
    SQL> insert into dd values (sysdate);
    1 row created.
    SQL> insert into dd values (sysdate);
    1 row created.
    SQL> insert into dd values (sysdate);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select * from dd;
    A
    01-OCT-12
    01-OCT-12
    01-OCT-12
    01-OCT-12
    01-OCT-12
    01-OCT-12
    6 rows selected.
    SQL>
    SQL>
    SQL> select to_date(a,'dd-mon-yyyy') from dd;
    TO_DATE(A
    01-OCT-12
    01-OCT-12
    01-OCT-12
    01-OCT-12
    01-OCT-12
    01-OCT-12
    6 rows selected.
    SQL> select to_timestamp(to_date(a,'dd-mon-yyyy'),'dd mon yy hh24.mi.ss' ) from dd;
    TO_TIMESTAMP(TO_DATE(A,'DD-MON-YYYY'),'DDMONYYHH24.MI.SS')
    01-OCT-12 12.00.00 AM
    01-OCT-12 12.00.00 AM
    01-OCT-12 12.00.00 AM
    01-OCT-12 12.00.00 AM
    01-OCT-12 12.00.00 AM
    01-OCT-12 12.00.00 AM
    6 rows selected.
    SQL>
    that's it......

Maybe you are looking for

  • How do I open the Special Edition Acrobat X PDF Portfolio themes?

    I chose these themes as my complimentary benefit when I installed Acrobat X, and downloaded the ZIP file to my hard drive without incident.  I then extracted the files within the ZIP file.  However, when I open Acrobat, and attempt to import the four

  • Optimum size for a full browser width image?

    Hi all, I'm pretty new to Muse and these forums (hello everyone!) and have been tinkering around with some features. I'm currently creating a website for my band that integrate a full width browser image at the top of each page. I was wondering what

  • HT4112 how do i pair bluetooth apple keyboard and iphone5?

    I am trying to pair my wireless bluetooth apple keyboard with my iPhone 5. It recognizes the keyboard but will not pair with it. What am I doing wrong? Thanks in advance!

  • How to make bpel wsdl accessible externally

    how can i make my bpel wsdl to be accessed by external system(outside our office network). its an asynchronous bpel .I am using SOA 11G. Thanks Edited by: user13374451 on Sep 28, 2010 8:01 PM

  • Benefit Salary for Insurance Plan

    Hi Experts, I need your help. I have a requirement to show the benefit salary in PA30 till the end of the month when an employee is terminated on any day of the month. Currently, the benefit salary in Insurance Coverage tab in PA30 is getting dispaly