我正在尝试将包含日期字符串的字符串分配给Oracle参数。
txtCommence.Text = '31//05/2018' --value is from the textbox
cmd.Parameters.Add(New OracleParameter(":pCommencementDate", OracleDbType.TimeStamp)).Value = txtCommence.Text
表中的时间戳存储为DD-MON-RR HH.MI.SSXFF AM。如何将txtcommence.text中的字符串值转换为表中所需的格式?
答案 0 :(得分:0)
如果可能,您可以将输入控件从cmd.CommandText = " ... WHERE COMMENCEMENT_DATE = TO_TIMESTAMP(:pCommencementDate, 'dd//mm/yyyy')"
cmd.Parameters.Add(New OracleParameter(":pCommencementDate", OracleDbType.Varchar2)).Value = txtCommence.Text
更改为 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = format.parse("2018-06-06");
String date = format.format(date1);
if(date.endsWith("01") && !date.endsWith("11"))
format = new SimpleDateFormat("d'st' MMM, yyyy");
else if(date.endsWith("02") && !date.endsWith("12"))
format = new SimpleDateFormat("d'nd' MMM, yyyy");
else if(date.endsWith("03") && !date.endsWith("13"))
format = new SimpleDateFormat("d'rd' MMM, yyyy");
else
format = new SimpleDateFormat("d'th' MMM, yyyy");
String yourDate = format.format(date1);
,以便直接获取日期值,而不是字符串。
无论如何,如果不可能,你应该像这样改变你的SQL:
class ClassificationType(object):
CLASSIFICATION_TYPE_UNSPECIFIED = 0
MULTICLASS = 1
MULTILABEL = 2
def dataset(model_typ_multiclass):
dataset_spec = {
"classification": model_typ_multiclass
}
obj = ClassificationType()
model_typ_multiclass = obj.MULTICLASS
dataset(model_typ_multiclass)