日期函数

yuanxn 2003-09-11 02:40:54
如何把当前服务器时间格式化成yyyymmdd形式,例如今天格式化成20030911
...全文
24 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljupin 2003-09-11
  • 打赏
  • 举报
回复
dim data
data = year(now)&month(now)&day(now)
Response.Write( data )
'data=2003911

dim data
data = year(now)&month(now)&day(now)
if len(month(now)) = 1 then
data = year(now)&"0"&month(now)&day(now)
end if
Response.Write( data )
' data=20030911
summergood 2003-09-11
  • 打赏
  • 举报
回复
关注 啊~
chinesun 2003-09-11
  • 打赏
  • 举报
回复
没问题。
<%
dim d,n,y,r
n=Year(date())
y=Month(date())
r=Day(date())
if len(cint(y))=1 then y="0" & cstr(cint(y))
if len(cint(r))=1 then r="0" & cstr(cint(r))
d=n&y&r
%>
<%=d%>
celerylhl 2003-09-11
  • 打赏
  • 举报
回复

''把日期型格式化为长日期型。
GetCurrentDate = FormatDateTime(yourdate, 1)
GetCurrentDate = FormatDateTime(yourdate, 1)

1为长日期格式,2为短日期格式,也就是你要的yyyy-m-d

chinesun 2003-09-11
  • 打赏
  • 举报
回复
没问题。
<%
dim d,n,y,r
n=Year(date())
y=Month(date())
r=Day(date())
if len(cint(y))=1 then y="0" & cstr(cint(y))
if len(cint(r))=1 then r="0" & cstr(cint(r))
d=n&"-"&y&"-"&r
%>
<%=d%>
johnnywang1980 2003-09-11
  • 打赏
  • 举报
回复
format,具体用法自己到MSDN上去查。
lyjlee 2003-09-11
  • 打赏
  • 举报
回复
<%
'产生以时间为序的随机数字
'返回值为:rndnum;
t=cstr(date())
do while len(t)>0
if left(t,1)=" " or left(t,1)="-" or left(t,1)=":" then
t=right(t,len(t)-1)
else
rndnum=rndnum&left(t,1)
t=right(t,len(t)-1)
end if
loop
%>
yuanxn 2003-09-11
  • 打赏
  • 举报
回复
可以吗

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧