sqlparser/sqlserver.cpp
// Convert interval +/- expression to DATEADD function
Convert interval +/- expression to DATEADD function
Convert interval + / - expression to DATEADD function
void SqlParser::SqlServerToDateAdd(Token *op, Token *first, Token *first_end, Token *second, Token *second_end)
{
	if(op == NULL || first == NULL || second == NULL)
		return;
	PREPEND(first, "DATEADD(");
	if(second->data_subtype == TOKEN_DT2_INTVL_MON)
		PREPEND_NOFMT(first, "mm");
	else
	if(second->data_subtype == TOKEN_DT2_INTVL_DAY)
		PREPEND_NOFMT(first, "dd");
	else
	if(second->data_subtype == TOKEN_DT2_INTVL_MIN)
		PREPEND_NOFMT(first, "mi");
	else
	if(second->data_subtype == TOKEN_DT2_INTVL_SEC)
		PREPEND_NOFMT(first, "ss");
	else
		PREPEND_NOFMT(first, "dd");
	PREPEND_NOFMT(first, ", ");
	if(TOKEN_CMPC(op, '-'))
		PrependCopy(first, op);
	PrependCopy(first, second, second_end, false);
	PREPEND_NOFMT(first, ", ");
	APPEND_NOFMT(first_end, ")");
	Token::Remove(op, second_end);
}
void SqlParser :: SqlServerToDateAdd ( Token * op , Token * first , Token * first_end , Token * second , Token * second_end ) { if ( op == NULL || first == NULL || second == NULL ) return ; PREPEND ( first , " " ) ; if ( second -> data_subtype == TOKEN_DT2_INTVL_MON ) PREPEND_NOFMT ( first , " " ) ; else if ( second -> data_subtype == TOKEN_DT2_INTVL_DAY ) PREPEND_NOFMT ( first , " " ) ; else if ( second -> data_subtype == TOKEN_DT2_INTVL_MIN ) PREPEND_NOFMT ( first , " " ) ; else if ( second -> data_subtype == TOKEN_DT2_INTVL_SEC ) PREPEND_NOFMT ( first , " " ) ; else PREPEND_NOFMT ( first , " " ) ; PREPEND_NOFMT ( first , " " ) ; if ( TOKEN_CMPC ( op , ' ' ) ) PrependCopy ( first , op ) ; PrependCopy ( first , second , second_end , false ) ; PREPEND_NOFMT ( first , " " ) ; APPEND_NOFMT ( first_end , " " ) ; Token :: Remove ( op , second_end ) ; }
Convert interval +/- expression to DATEADD function
Convert interval + / - expression to DATEADD function
// Copy - sign only, + will not be used