[ 
https://issues.apache.org/jira/browse/TRAFODION-3127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16541043#comment-16541043
 ] 

ASF GitHub Bot commented on TRAFODION-3127:
-------------------------------------------

Github user kakaxi3019 commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1632#discussion_r201892154
  
    --- Diff: core/sql/exp/exp_datetime.cpp ---
    @@ -3294,6 +3338,39 @@ convertMonthToStr(Lng32 value, char *&result, UInt32 
width)
       result += width;
     }
     
    +static void
    +convertDayOfWeekToStr(Lng32 value, char *&result, NABoolean bAbbreviation, 
UInt32 width)
    +{
    +  const char* dayofweek[] =
    +  {
    +    "SUNDAY   ",
    +    "MONDAY   ",
    +    "TUESDAY  ",
    +    "WEDNESDAY",
    +    "THURSDAY ",
    +    "FRIDAY   ",
    +    "SATURDAY "
    +  };
    +
    +  const char* dayofweek_abb[] =
    +  {
    +    "SUN",
    +    "MON",
    +    "TUE",
    +    "WED",
    +    "THU",
    +    "FRI",
    +    "SAT"
    +  };
    +
    +  if (bAbbreviation)
    +    strcpy(result, dayofweek_abb[value-1]);
    +  else
    +    strcpy(result, dayofweek[value-1]);
    +  // Update result pointer to point to end of string.
    +  result += width;
    --- End diff --
    
    Yes. The string length is always 3 or 9, so i assign the value for width. 
    For example 
    strlen("SUNDAY")=6, but strlen("WEDNESDAY")=9. 
    so the length will always be 9.
    But here "SUNDAY   "(with 3 whitespace), so your suggestion is good, thank 
you!


> to_char enhancement
> -------------------
>
>                 Key: TRAFODION-3127
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-3127
>             Project: Apache Trafodion
>          Issue Type: Improvement
>            Reporter: chenyunren
>            Assignee: chenyunren
>            Priority: Major
>
> |Pattern|Description|EXP.|
> |HH|  hour of day (00-23)|TO_CHAR (TIME '23:05:10','HH')
>  result:23|
> |HH12|  hour of day (01-12)|TO_CHAR (TIME '23:05:10','HH')
>  result:11|
> |HH24|hour of day (00-23)|TO_CHAR (TIME '23:05:10','HH')
>  result:23|
> |MI|minute (00-59)|TO_CHAR (TIME '23:05:10','MI')
>  result:05|
> |SS|second (00-59)|TO_CHAR (TIME '23:05:10','SS')
>  result:10|
> |YYYY|year (4  digits)|TO_CHAR (TIMESTAMP '2016-03-01 12:05:10','YYYY')
>  result:2016|
> |Y|Last digit of the year (0-9)| TO_CHAR (TIMESTAMP '2016-03-01 12:05:10','Y')
>  result:6|
> |YY|Last two digits of the year (00-99)| TO_CHAR (TIMESTAMP '2016-03-01 
> 12:05:10','YY')
>  result:16|
> |YYY|Last three digits of the year (000-999)| TO_CHAR (TIMESTAMP '2016-03-01 
> 12:05:10','YYY')
>  result:016|
> |MON|month(3 chars in English)|TO_CHAR (TIMESTAMP '2016-03-01 12:05:10','MON')
>  result:MAR|
> |MM|month(01-12)|TO_CHAR(DATE '2006-12-01','MM')
>  result:12|
> |DY|name of day(3 chars in English) |TO_CHAR (TIMESTAMP '2016-03-01 
> 12:05:10','DY')
>  result:TUE|
> |DAY|Name of day, padded with blanks to length of 9 characters. 
> SUNDAY|TO_CHAR (TIMESTAMP '2016-03-01 12:05:10','DY')
> result:TUESDAY|
> |CC|century|TO_CHAR (TIMESTAMP '2016-03-01 12:05:10','CC')
>  result:21|
> |D|day of week(Sunday (1) to Saturday (7))|TO_CHAR (TIMESTAMP '2016-03-01 
> 12:05:10','D')
>  result:3|
> |DD|day of month(01-31)|TO_CHAR(DATE '2006-12-01','DD')
>  result:01|
> |DDD|day of year(1-366)|TO_CHAR(DATE '2006-12-01','DDD')
>  result:335|
> |W|week of month(1-5)|TO_CHAR(DATE '2006-12-31','W')
>  result:5|
> |WW|week number of year(1-53).The first week starts on the first day of the 
> month.|TO_CHAR(DATE '2006-01-02','WW')
>  result:01|
> |J|Julian day (number of days since January 1, 4713 BC)|TO_CHAR(TIMESTAMP 
> '2001-01-07 00:00:00','J')
>  result:2451917|
> |Q|The quarter of the year (1 - 4)|TO_CHAR(DATE '2006-12-01','Q')
>  result:4|



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to