Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2013
    Posts
    4

    Unanswered: current -1 monthe issue

    '86' || mmddyy || '20'

    (mmddyy should correspond to the last day of the processing month; if day = 1 then lastday of previous month, else lastday of current month


    use the belwo query to get this


    values case when day(current_date) = 1 then LAST_DAY(current_date - 1 month) Else Last_day(current_date) end


    but giving me resut
    2014-01-31

    i need output 2013-12-31.


    can soembody help me on this.

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    as today is 22/1 (else lastday of current month) the output is correct
    or the need is different and not well described
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    case when day(current_date) = 1 then LAST_DAY(current_date - 1 month) Else Last_day(current_date) end
    The expression might be simplified like
    LAST_DAY(current_date - 1 DAY)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •