Skip to content
This repository was archived by the owner on Jun 7, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/sql/exp/exp_datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3686,6 +3686,8 @@ ExpDatetime::convDatetimeToASCII(char *srcData,
{
if (hour > 12)
hour = hour - 12;
if ( 0 == hour )
hour = 12;
}
convertToAscii(hour, dstDataPtr, 2);
return (dstDataPtr - dstData);
Expand Down Expand Up @@ -3809,10 +3811,8 @@ ExpDatetime::convDatetimeToASCII(char *srcData,
int weekofmonth = 0;
if ( day )
{
Int64 interval = getTotalDays(year, 1, 1);
int dayofweek = (int)(((interval + 1) % 7) + 1);
int dayofyear = Date2Julian(year,month,day)-Date2Julian(year,1,1)+1;
weekofmonth = (dayofyear-1+dayofweek-1)/7+1;
weekofmonth = (dayofyear-1)/7+1;
}
convertToAscii(weekofmonth,dstDataPtr,2);
return (dstDataPtr - dstData);
Expand Down
11 changes: 7 additions & 4 deletions core/sql/exp/exp_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,11 @@ static Int64 lcl_interval(rec_datetime_field eField, Lng32 eCode, char *opdata,
{
short nValue;
str_cpy_all((char *) &nValue, opdata, sizeof(nValue));
if ( 0 == nValue )
return 1;
nValue = nValue % 12;
if ( 0 == nValue )
return 4;
return (nValue-1)/3+1;
}
if ( REC_DATE_EPOCH == eField )
Expand Down Expand Up @@ -3173,11 +3178,9 @@ Int64 ex_function_extract::getExtraTimeValue(rec_datetime_field eField, Lng32 eC
return year/10;
}
case REC_DATE_WEEK:
{//same with built-in function week ITM_WEEK
Int64 interval = datetimeOpType->getTotalDays(year, 1, 1);
Int64 dayofweek = lcl_dayofweek(interval);
{
Int64 dayofyear = lcl_dayofyear(year,month,day);
return (dayofyear-1+dayofweek-1)/7+1;
return (dayofyear-1)/7+1;
}
case REC_DATE_QUARTER:
{
Expand Down