| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2004 人关注过本帖
标题:如何让时间只显示月日时呢?
只看楼主 加入收藏
dushui265
Rank: 1
等 级:新手上路
威 望:2
帖 子:227
专家分:0
注 册:2007-9-28
收藏
 问题点数:0 回复次数:4 
如何让时间只显示月日时呢?

我数据库中的日期格式是完整的,现在只想在页面中显示月日时,如何实现呢??

搜索更多相关主题的帖子: 月日 数据库 时间 格式 页面 
2007-10-02 10:54
litianyi520
Rank: 1
等 级:新手上路
帖 子:75
专家分:0
注 册:2006-5-18
收藏
得分:0 

year(rs(“time”))
month(rs(“time”))
date(rs(“time”))

2007-10-02 17:22
tianyu123
Rank: 1
等 级:新手上路
威 望:2
帖 子:576
专家分:0
注 册:2007-8-26
收藏
得分:0 
以下是引用litianyi520在2007-10-2 17:22:24的发言:

year(rs(“time”))
month(rs(“time”))
date(rs(“time”))

应该为:

day(rs("time"))


改变一切,须从改变观念开始!
2007-10-02 21:32
dushui265
Rank: 1
等 级:新手上路
威 望:2
帖 子:227
专家分:0
注 册:2007-9-28
收藏
得分:0 
谢谢楼上各位了!!!!

2007-10-03 10:21
天涯听雨
Rank: 2
来 自:东莞
等 级:论坛游民
威 望:4
帖 子:497
专家分:64
注 册:2007-8-25
收藏
得分:0 
'该函数作用:按指定参数格式化显示时间。
'numformat=1:将时间转化为yyyy-mm-dd hh:nn格式。
'numformat=2:将时间转化为yyyy-mm-dd格式。
'numformat=3:将时间转化为hh:nn格式。
'numformat=4:将时间转化为yyyy年mm月dd日 hh时nn分格式。
'numformat=5:将时间转化为yyyy年mm月dd日格式。
'numformat=6:将时间转化为hh时nn分格式。
'numformat=7:将时间转化为yyyy年mm月dd日 星期×格式。
'numformat=8:将时间转化为yymmdd格式。
'numformat=9:将时间转化为mmdd格式。
Function FormatDate(shijian,numformat)
dim ystr,mstr,dstr,hstr,nstr '变量含义分别为年字符串,月字符串,日字符串,时字符串,分字符串

if isnull(shijian) then
numformat=0
else
ystr=DatePart("yyyy",shijian)

if DatePart("m",shijian)>9 then
mstr=DatePart("m",shijian)
else
mstr="0"&DatePart("m",shijian)
end if

if DatePart("d",shijian)>9 then
dstr=DatePart("d",shijian)
else
dstr="0"&DatePart("d",shijian)
end if

if DatePart("h",shijian)>9 then
hstr=DatePart("h",shijian)
else
hstr="0"&DatePart("h",shijian)
end if

if DatePart("n",shijian)>9 then
nstr=DatePart("n",shijian)
else
nstr="0"&DatePart("n",shijian)
end if

if DatePart("s",shijian)>9 then
sstr=DatePart("s",shijian)
else
sstr="0"&DatePart("s",shijian)
end if
end if

select case numformat
case 0
FormatDate=ystr&"-"&mstr&"-"&dstr&" "&hstr&":"&nstr&":"&sstr
case 1
FormatDate=ystr&"-"&mstr&"-"&dstr&" "&hstr&":"&nstr
case 2
FormatDate=ystr&"-"&mstr&"-"&dstr
case 3
FormatDate=hstr&":"&nstr
case 4
FormatDate=ystr&"年"&mstr&"月"&dstr&"日 "&hstr&"时"&nstr&"分"
case 5
FormatDate=ystr&"年"&mstr&"月"&dstr&"日"
case 6
FormatDate=mstr&"月"&dstr&"日 "&hstr&"时"&nstr&"分"
case 7
FormatDate=ystr&"年"&mstr&"月"&dstr&"日 "&WeekdayName(Weekday(shijian))
case 8
FormatDate=right(ystr,2)&mstr&dstr
case 9
FormatDate=mstr&dstr
end select
End Function

从明天起做幸福的人,喂马劈柴周游世界!
2007-10-04 11:29
快速回复:如何让时间只显示月日时呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018703 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved