To_char function not working

hi,
I want to get the max dates on format MM/DD/YYYY. the problem is it only works on
select distinct
t.id,
max(to_char (t.tr_date,'MM/DD/YYYY')) as transaction_date,
s.contract_date,
max(i.start_date) as start_date,
max(i.end_date) as end_date
from trans_history t,
subscription s,
inv i
where t.prod='FTU'
and t.tr_date >='01-January-2010'
and s.id=t.id
and i.id=t.id
and t.id=1983634
group by
t.id,
s.contract
result:
Id Transaction Date Contract Start Date End Date
1983634 03/10/2010 11/01/2008 17/03/2010 29/03/2010
then if I change the query like below: im not getting the max values of start date and end date
select distinct
t.id,
max(to_char (t.tr_date,'MM/DD/YYYY')) as transaction_date,
s.contract_date,
max(to_char(i.start_date,'MM/DD/YYYY')) as start_date,
max(to_char(i.end_date,'MM/DD/YYYY')) as end_date
from trans_history t,
subscription s,
inv i
where t.prod='FTU'
and t.tr_date >='01-January-2010'
and s.id=t.id
and i.id=t.id
and t.id=1983634
group by
t.id,
s.contract
I'm wondering why to_char only works on t.tr_date field.
please help.

Hi,
Almost always, TO_CHAR is the last operation you do to DATEs. Do things like MAX before you convert the DATE to a string:
to_char ( max (t.tr_date)
        , 'MM/DD/YYYY'
        )When comparing the followig strings
'12/01/2008'
'07/01/2009'
'01/30/2010'the greatest is '12/01/2008', because '12' is greater than '07' and '01'.
You can change the default format for all DATEs in your session like this:
ALTER SESSION  SET  NLS_DATE_FORMAT = 'MM/DD/YYYY';Then you might not need TO_CHAR at all.
Edited by: Frank Kulash on Jul 23, 2010 6:51 AM

Similar Messages

  • Not able to sign into Blackberry Protect. Backup and Restore function not working. "Your device isn't associated with a Blackberry ID"

    Not able to sign into Blackberry Protect.  Backup and Restore function not working. Message is: "Your device isn't associated with a Blackberry ID."  My Blackberry Messenger and Blackberry World is working fine so I am sure its not an ID issue on the phone.  I can sign into Link, Blackberry.com and Protect.  I see my device in Protect but cannot send messages or view it on a map.  Times out with cannot reach device message.  BB Protect on Device has a swirling circle beside the on/of switch.  Cannot turn off.  
    I have deleted Link and re-installed.
    I have reset phone to default(factory) and signed in. 
    OS level is 10.2.1.3062
    BB Link is 1.2.3.56
    Solved!
    Go to Solution.

    I managed to figure this out myself. I had to delete the device from the Blackberry Protect website.  protect.blackberry.com.  I wiped my device again and signed in with my Blackberry ID.  I dont know if the step of wiping was necessary as I did not try my backup with the current configuration on the device following the delete.  Restore is in progress for me!

  • Copy/paste function not working in Firefox 22. Always good in previous versions

    Copy/paste function not working in Firefox 22. Always good in previous versions editions

    Well I've uninstalled FF22, thanks for the suggestion.
    Chrome works perfectly with ZA and C&P.

  • Why is the scroll function not working after accessing the voice feature in settings?

    Why is the scroll function not working after accessing the voice feature in settings?

    For some prerecorded audio files the Transpose slider will not work reliably. I found no clear pattern, when it does and when not.
    If all fails, create a loop from the audio file. Select the region in the track and use the command "File: Add region to Loop library".
    Set the current key and tempo, name the loop, and save the loop.
    Now add it from the loop browser to a new track and delete your old track. The search field in the Loop browser will help you to find the loop quickly.
    You will be able to transpose the sample as described above, like a regular loop.
    For example - a audio file turned into a loop and transposed:

  • MDX -Children count function Not working in Case statement

    Hi,
    I am trying to create set when you slice with the Hierarchy member is leaf level , I want a output only that Leaf level .
    and When I slice with  the parent level , it has to give all the members below that parent level.
    But the problem here is when I select child member or leaf member , The first condition in the Case is not working
    WITH SET
    TESTSET AS
    CASE
    WHEN
     [Dimension].[Hierarchy].currentmember.children.count<0
    THEN
     [Dimension].[Hierarchy].currentmember
    ELSE
     DESCENDANTS([Dimension].[Hierarchy].Currentmember,,AFTER)
    END
    SELECT
    WBSSET ON 1,
    {} on 0
    FROM
     (SELECT {[Dimension].[Hierarchy].&[10]} ON COLUMNS FROM [CubeName])
    Thanks,
    Santosh

    Hi Santosh,
    I don't think Children count function not working in case statement, I have tested it on my local environment, here s the sample query for you reference.
    with member
    testset as
    case
    when
    [Geography].[Geography].currentmember.children.count<10
    then "X"
    else "OK"
    end
    select testset on 0,
    {[Geography].[Geography].[Country].members} on 1
    from
    [Adventure Works]
    In your scenario, the issue might be caused by the query isself, you can try to use IsLeaf Funcion to achieve your requirement. Please refer to the links below.
    http://msdn.microsoft.com/en-us/library/ms144932.aspx
    http://www.databasejournal.com/features/mssql/article.php/3633696/MDX-Operators-The-IsLeaf-Operator--Conditional-Logic-within--Calculations.htm
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=22
    Regards,
    Charlie Liao
    TechNet Community Support

  • Palm Desktop 6.2.2. and Lookup function not working in Windows 7

    Palm Desktop's lookup function not working in Windows 7 64bit. Please help.
    Post relates to: Centro (Verizon)
    This question was solved.
    View Solution.

    I was able to solve this by unchecking compatibility mode and setting the application to run as administrative.

  • Send & Recieve functionality not working with  WebDav after installing Acrobat XI

    Send & Recieve functionality not working with  WebDav after installing Acrobat XI for PDF.  Acrobat XI is complete installations(Trial Version).

    Hi Kiro ,
    Did you try opening that file in any other browser ?If not ,please try doing that once and see if that  works for you.
    Try Repairing Acrobat once and see if  that helps.
    Launch Acrobat>Navigate to Help>Repair Acrobat Installation.
    Regards
    Sukrit Dhingra

  • Keyboard + mouse functions not working

    After updating InDesign CC 6-days ago started to have issue with all keyboard + mouse functions not working ex. shift key does not constrain proportions when scaling. A restart fixed the issue thr first time. Today I have installed latest update and shut down and restarted several times does not fix issue. On a MacBook pro running OS X Mavericks 10.9.2.

    Disconnected extrenal devices ie keyboard and Wacom Bamboo tablet and restarted computer seemed to correct the issue.

  • In my ipad zoom function not working..some day before it worked,but when i double pinch with my three fingers it zooms negligible, wat to do?plzz help me..

    In my ipad zoom function not working..some day before it worked,but when i double pinch with my three fingers it zooms negligible, wat to do?plzz help me..

    It works when I reset my all settings...
    Settings>general>reset>reset all settings
    It never delete ur all contacts and any others,but ur wallpaper and wifi connection will change..it can be as before...

  • HT204168 touch screen function not working when using facetime

    Why is my iPad touch screen function not working when using FaceTime?

    Hi megascones,
    I apologize, I'm a bit unclear on the exact nature or scope of the issue you are describing. If you are having issues with the touch screen on your iPad, you may find the troubleshooting steps outlined in the following article helpful:
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Regards,
    - Brenden

  • Why is my touch screen function not working when using facetime

    Why is my touch screen function not working when using facetime

    Hello megascones,
    After reviewing your post, it sounds like the screen is not responding to touch in one app. I would recommend that you read this article, it may be able to help the issue.
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Restart your device. If you can't restart, reset your device.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • HT1977 I bought apps. My kid delet that after few weeks. Then I have downloaded to same ipad. But some functions not working.

    I purchase some apps, my son deleted some. But I have download again from cloud. But some functions not working ask me to pay again. How can I use functions without paying again.   Thank you

    Search around on the app settings and see if there's a "Restore purchases" option.

  • After upgrading to maverick; help & other functions not working

    After upgrading to maverick; help and other functions not working?

    Sometimes just closing and reopening the Help window will clear up the problem. If it doesn't, log out or restart the computer and try again. Otherwise, you may need to delete the Help cache.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Caches/com.apple.helpd
    Right-click or control-click the highlighted line and select 
    Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder selected. Move the selected folder to the Trash. Log out, log back in, and test. Help pages will be slow to load at first.
    If that doesn't work, the problem may be caused by network conditions. It may go away by itself, though I can't say how long you should wait.
       A persistent failure to load help data has been reported as an issue with satellite networks. Test on a different network, if possible. I've also seen at least one report that Photo Stream in iCloud can mysteriously interfere with Help. I'm not sure whether that's true, but try disabling Photo Stream, if applicable.*If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combinationcommand-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • To date function not working

    Hi,
    I have been searching for hours to solve this problem.
    I can´t convert a date to only year, month or day etc...
    select sysdate, TO_DATE(sysdate,'YYYY') from dual
    ORA-01830: date format picture ends before converting entire input string
    01830. 00000 - "date format picture ends before converting entire input string"
    select sysdate, TO_DATE(sysdate,'MM') from dual
    ORA-01843: not a valid month
    01843. 00000 - "not a valid month"
    select sysdate, TO_DATE(sysdate,'DD') from dual
    ORA-01830: date format picture ends before converting entire input string
    01830. 00000 - "date format picture ends before converting entire input string"
    Please, if this is not the right category to post in just address me to the right one.
    Thanks,

    user12981132 wrote:
    Many thanks to all,
    Indeed in worked on the sysdate. But I still have a similar problem. I wanted to provide an example you could reproduce on your own, that´s why I used the sysdate from dual. But my main problem is that I have a VARCHAR2(8 BYTE) data type for a date, when a try to format it to a date it returns the same error:
    Ok, so because your real data is a varchar instead of a DATE, your example with sysdate was nothing like reality.
    select fealta from david.socipart
    returns for example: 19140731So it looks like your varchar data that represents a date is in the format yyyymmdd.
    >
    when I want to change it to date and get year, month, day as before it doesn´t work. And in this case I am not trying to convert the same data type:
    select to_date(fealta,'yyyy') from david.socipartAnd here you try to convert your varchar to a DATE, but you are telling to_date to interpret the character string as if it were simply YYYY, which of course ends before the actual data ends .....
    ORA-01830: date format picture ends before converting entire input string
    01830. 00000 - "date format picture ends before converting entire input string"
    ... resulting in an error message that tells you that.
    select to_date(fealta,'rrrr') from david.socipart
    ORA-01830: date format picture ends before converting entire input string
    01830. 00000 - "date format picture ends before converting entire input string"
    select to_date(fealta,'mm') from david.socipart
    ORA-01843: not a valid month
    01843. 00000 - "not a valid month"
    select to_date(fealta,'dd') from david.socipart
    ORA-01830: date format picture ends before converting entire input string
    01830. 00000 - "date format picture ends before converting entire input string"
    But when I do this it works fine:
    select to_date(fealta,'yyyymmdd') from david.socipart
    1914/07/31
    So, finally you gave to_date the correct description of your character string. And when you did, oracle then had to follow up with an implied use of to_char to convert the DATE back to a character string for presentation in the output. It used the controlling setting of NLS_DATE_FORMAT to do so.
    * I did a alter session to change the date format to yyyy/mm/ddYour fundamental error is not understanding the difference between a DATE and a character string (VARCHAR2) the represents a DATE.
    And from that misunderstanding comes a misunderstanding of the use and purpose of the to_date and to_char functions, as well as the horrible design error of using a VARCHAR column to try to store a DATE.
    see: [url http://edstevensdba.wordpress.com/2011/04/07/nls_date_format/] But I want to store my date as ...
    Edited by: EdStevens on May 14, 2013 10:15 AM

  • Partner function not working when creating PO with ref to PReq

    Partner function is not working when creating a Purchase Order with ref to a Purchase Requistion, Partner functions maintained in the vendor master are VN, OA & PI.
    But OA & PI are not appearing in the PO header partner tab when created with ref to PR.
    however it works when i create the PO directly ( without the PR ref )
    I am using the same material & Plant for both manual PO & PR to PO.
    Any idea what could be wrong .
    I have maintained the settings for schema groups for vendor master & purchasing doc in the partner determination.
    Thanks
    Dkmurthy

    Hi,
    I have also an issue that seems similar to one you are discussing.
    When we use ME59N and create a PO with ref. from a PR (created from a sales order), the message determination works well, it reads the condition set in MN04 (condition records for messages), and creates a message (with output type for EDI , medium: 6, and partner function LS: Logical system). Message is created and idoc is sent.
    When we try with ME21N, ME21 and we create the PO with ref. to the same PR, either by entering manually the PR in the document overview of ME21N or by selecting the PR (without entering the PR number), i.e with date, the message is not created in the PO.
    Company code is assigned to purchase organization, and so is purchase organization to plant.
    Any idea why there is no automatic message determination in the case of the transaction: ME21N
    Note: If I try ME21N, and enter the output type and partner, manually, I receive a warning message
    VN006 (Partner XXXX does not exist for partner function LS). If I accept this warning message, then message is saved- idoc is sent. However I can not overcome the warning message, if it plays any role, because I can not assign partner function LS to the vendor.Then I receive message CZ 327 (Can not use this partner role).
    Any input is wellcome.

Maybe you are looking for

  • June 2014 Muse Update Fail

    I've tried to update to the June 2014 Muse update. I sign in at Adobe and click on download. The window says the file is downloading, but nothing happens, I've tried using Firefox and Safari. not sure what else to do. Also, I'm not sure what the AAR

  • Why does my email password keep having to be renewed?

    this is the second time recently that my email to the BB has been stopped because I need to change my email password. Why does this keep happening? I have changed nothing in my cox.net email account. You are doing something. I can't find a phone numb

  • Does HP M1005 MFP printer supports multi-page scanning? Can it be run on windows 8 64 bit?

    I have a HP M1005 MFP printer which i usually connect on windows 8 64 bit. I require multi-page scanning for making pdf documents. Can we perform multi-page scanning in HP M1005 MFP? Help appriciated. Thank You. 

  • How come type appears fuzzy when we preview articles on the iPad?

    Hi, I need some help. How come type appears fuzzy when we preview articles on the iPad? Thanks!

  • Join issues with Multicube reports

    I experts, We have a Multicube M  with a Real time cube A and Basic Cube B.  Cube B was added to the Multicube recently. Cube A contains Phasing data ( like Forecast) for Opportunities. See some eg records below. Oppt PERIOD KF1 001   001       10 00