如何判断传过来的参数是否是时间类型

如何判断传过来的参数是否是时间类型,第1张

DateTime StartTime = ConvertToDateTime(DateTimeNowToShortDateString());

string StrSelect = RequestForm["dtSelect"]ToString();

SearchInfoStartTime =StrSelect;

if (SearchInfoStartTime != "")

{

if (!(DateTimeTryParse(SearchInfoStartTime, out StartTime))) //同理其他类型也可如法炮制的进行判断

{

SearchInfoStartTime = "2012-1-4";

}

}

time变量不知是日期还是时间,如果是日期可以用pwliupeng的答案,如果是时间,采用JavaScript进行判断:

<script language="javascript">

<!--

function CheckLogin(form){

if(formtimevalueindexOf(':',':')==-1){

alert("不是时间格式,请重新输入!");return false;

}

formsubmit();return true;

}

-->

</script>

在客户端的提交页!

</select>

<SELECT size="1" name="y">

<OPTION value="">-=请选择年度=-</OPTION>

<%

Dim ii

For ii=2011 To 2013

%>

<option value="<%=ii%>" <%if ii=year(date()) then ResponseWrite("selected")%>><%=ii%>年</option>

<%next%>

</SELECT>

<SELECT size="1" name="m">

<OPTION value="">-月度-</OPTION>

<%

For ii=1 To 12

%>

<option value="<%=ii%>" <%if ii=month(date()) then ResponseWrite("selected")%>><%=ii%>月</option>

<%next%>

</SELECT>

<SELECT size="1" name="d">

<OPTION value="">-日期-</OPTION>

<%

For ii=1 To 31

%>

<option value="<%=ii%>" <%if ii=day(date()) then ResponseWrite("selected")%>><%=ii%>日</option>

<%next%>

</SELECT>

<input type="submit" value="统计"/></td>

</form>

<td align="center" bgcolor="f7f7f7">

<span class="note">年度必选,月度可选,商户可选。</span>

</td>

</tr>

</table>

<%

Dim page,i

if request("action") = "add" then

call add()

elseif request("action")="edit" then

call edit()

elseif request("action")="savenew" then

call savenew()

elseif request("action")="savedit" then

call savedit()

elseif request("action")="del" then

call del()

elseif request("action")="delAll" then

call delAll()

elseif request("action")="copy" then

call copy()

else

call List()

end if

sub List()

%>

<form name="myform" method="POST" action="inaspaction=delAll">

<table width="95%" border="0" align=center cellpadding="3" cellspacing="1" bgcolor="#F2F9E8" class="admintable">

<tr>

<td colspan="14" align=left class="admintitle">销售收入列表  [<a href="action=add" class="add">添加</a>]</td></tr>

<tr bgcolor="#f1f3f5" style="font-weight:bold;">

<td width="3%" height="30" align="center" class="ButtonList"> </td>

<td align="center" class="ButtonList">商户名称</td>

<td align="center" class="ButtonList">记录时间</td>

<td align="center" class="ButtonList">订单金额</td>

<td align="center" class="ButtonList">全款</td>

<td align="center" class="ButtonList">订金</td>

<td align="center" class="ButtonList">未付款</td>

<td align="center" class="ButtonList">订金补款</td>

<td align="center" class="ButtonList">退货金额</td>

<td align="center" class="ButtonList">现金</td>

<td align="center" class="ButtonList">划卡</td>

<td align="center" class="ButtonList">划卡手续费</td>

<td align="center" class="ButtonList">实际收款</td>

<td align="center" class="ButtonList">单号</td>

</tr>

<%

Dim Hits,s,y,d,m,i_name,i_name1,keyword,mysql

dim count_sd,count_gwgz,count_gngz,count_ylbx1,count_ylbx2,count_zfgjj,count_sybx,count_nj,count_sds,count_jj,count_qt

count_sd=0

count_gwgz=0

count_gngz=0

count_ylbx1=0

count_ylbx2=0

count_zfgjj=0

count_sybx=0

count_nj=0

count_sds=0

count_jj=0

count_qt=0

Hits=request("hits")

s=Request("s")

y=Request("y")

m=Request("m")

d=Request("d")

i_name=request("i_name")

i_name1=request("i_name1")

keyword=request("keyword")

mysql="select from [{pre}in]"

if s="bz" then

mysql=mysql&" Where i_bz<>''"

elseif s="jj" then

mysql=mysql&" Where i_jj<>0"

elseif s="qt" then

mysql=mysql&" Where i_qt<>0"

elseif s="sds" then

mysql=mysql&" Where i_sds<>0"

elseif i_name<>"" then

mysql=mysql&" Where i_name='"&i_name&"'"

elseif keyword<>"" then

mysql=mysql&" Where i_bz like '%"&keyword&"%'"

End if

if y<>"" and m<>"" and d<>"" then

mysql=mysql&" Where year(i_date)="&y&" and month(i_date)="&m&" and day(i_date)="&d&" "

elseif y<>"" then

mysql=mysql&" Where year(i_date)="&y&" "

elseif d<>"" then

mysql=mysql&" Where day(i_date)="&d&" "

end if

if i_name1<>"" then

mysql=mysql&" and i_name='"&i_name1&"'"

end if

mysql=mysql&" order by "

If Hits=1 then

mysql=mysql&"i_sd desc"

Else

mysql=mysql&"i_date desc"

End if

set rs=db(mysql,2)

if Not rseof then

%>

<%

DateTIme 类型吧?不要直接传值或者 ToString() 就完了,指定好格式,比如你要的这个格式是:

DateTimeNowToString("yyyy/MM/dd HH:mm:ss");

直接用vb转换GMT时间

Private Function getWebDatetime() As String

Dim Xml>

Set Xml>

Xml>

Xml>

getWebDatetime = CDate(1 / 3 + CDbl(CDate(Mid$(Xml>

Set Xml>

End Function

扩展资料:

读取网站服务器返回的时间的代码

Private Function getWebDatetime() As String

Dim Xml>

Set Xml>

Xml>

Xml>

Set objJs = CreateObject("msscriptcontrolscriptcontrol")

objJsLanguage = "jScript"

getWebDatetime = objJsEval("var dt = new Date('" & Xml>

Set Xml>

Set objJs = Nothing

End Function

以上就是关于如何判断传过来的参数是否是时间类型全部的内容,包括:如何判断传过来的参数是否是时间类型、ASP中如何判断时间格式是否符合要求、sql server用年月日select时间,时间的类型是datename等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/10094423.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存