CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

日期显示的格式???

楼主melted(天使)2005-08-22 13:19:04 在 Web 开发 / ASP 提问

怎样才能够让日期显示这样:  
   
   
  Wednesday,   August   04,   1999 问题点数:20、回复次数:7Top

1 楼melted(天使)回复于 2005-08-22 13:22:56 得分 0

我只知道用这个函数  
   
  FormatDateTime()  
    FUNCTION:   返回表达式,此表达式已被格式化为日期或时间  
    SYNTAX:   FormatDateTime(Date,   [,   NamedFormat>)  
    ARGUMENTS:   NamedFormat   指示所使用的日期/时间格式的数值,如果省略,则使用   vbGeneralDate.  
    EXAMPLE:   <%=FormatDateTime("08/4/99",   vbLongDate)%>  
    RESULT:   Wednesday,   August   04,   1999  
   
  具体改怎么用呢?》Top

2 楼ShiningstarHu(Shining_star)回复于 2005-08-22 13:23:09 得分 0

<%  
      =FormatDateTime(Now,   1)  
  %>Top

3 楼melted(天使)回复于 2005-08-22 13:27:31 得分 0

楼上什么意思??Top

4 楼geniusxch(天使)回复于 2005-08-22 14:37:49 得分 0

 
  FormatDateTime()  
    FUNCTION:   返回表达式,此表达式已被格式化为日期或时间  
    SYNTAX:   FormatDateTime(Date,   [,   NamedFormat>)  
    ARGUMENTS:   NamedFormat   指示所使用的日期/时间格式的数值,如果省略,则使用   vbGeneralDate.  
    EXAMPLE:   <%=FormatDateTime("08/4/99",   vbLongDate)%>  
    RESULT:   Wednesday,   August   04,   1999Top

5 楼brothercat(猫猫 ^_^)回复于 2005-08-22 15:55:11 得分 0

星期几可以用weekday()取到。  
   
  其它的如下:  
  <%  
  Dim   datestr1   'as   string  
  datestr1=Now()  
  Response.Write   DCF(datestr1)  
   
  'Response.End  
  '   Response.Write   (22+2*8+3*(8+1)/5+2005+2005/4-2005/100+2005/400)   mod   7+1  
  %>  
  <%  
  Function   DCF(datestr)  
  Dim   ConvertDate  
  ConvertDate=FormatDateTime(datestr,vbShortDate)  
   
  Dim   strLen  
  strLen=Len(ConvertDate)  
   
  Dim   yearstr  
  yearstr=Left(ConvertDate,4)  
   
  Dim   monthstr,daystr  
  '//2005-12-11  
  If   strLen=10   Then  
  monthstr=Mid(ConvertDate,6,2)  
  daystr=Right(ConvertDate,2)  
  Elseif   strLen=9   Then  
  '//2005-7-23  
  If   Mid(ConvertDate,7,1)="-"   Then  
  monthstr=Mid(ConvertDate,6,1)  
  daystr=Right(ConvertDate,2)  
  '//2005-12-3  
  Else  
  monthstr=Mid(ConvertDate,6,1)  
  daystr=Right(ConvertDate,2)  
  End   If  
  '//2005-1-8  
  Else  
  monthstr=Mid(ConvertDate,6,1)  
  daystr=Right(ConvertDate,1)  
  End   If  
   
  Dim   monthstrToEn  
  Select   Case   monthstr  
  Case   "1"  
  monthstrToEn="January"  
  Case   "2"  
  monthstrToEn="February"  
  Case   "3"  
  monthstrToEn="March"  
  Case   "4"  
  monthstrToEn="April"  
  Case   "5"  
  monthstrToEn="May"  
  Case   "6"  
  monthstrToEn="June"  
  Case   "7"  
  monthstrToEn="July"  
  Case   "8"  
  monthstrToEn="August"  
  Case   "9"  
  monthstrToEn="September"  
  Case   "10"  
  monthstrToEn="October"  
  Case   "11"  
  monthstrToEn="November"  
  Case   "12"  
  monthstrToEn="December"  
  End   Select  
   
  DCF=monthstrToEn&","&daystr&","&yearstr  
   
  End   Function  
  %>  
  Top

6 楼brothercat(猫猫 ^_^)回复于 2005-08-22 15:57:06 得分 0

写错了一个地方,应该是:  
  <%  
  Dim   datestr1   'as   string  
  datestr1=Now()  
  Response.Write   DCF(datestr1)  
   
  'Response.End  
  '   Response.Write   (22+2*8+3*(8+1)/5+2005+2005/4-2005/100+2005/400)   mod   7+1  
  %>  
  <%  
  Function   DCF(datestr)  
  Dim   ConvertDate  
  ConvertDate=FormatDateTime(datestr,vbShortDate)  
   
  Dim   strLen  
  strLen=Len(ConvertDate)  
   
  Dim   yearstr  
  yearstr=Left(ConvertDate,4)  
   
  Dim   monthstr,daystr  
  '//2005-12-11  
  If   strLen=10   Then  
  monthstr=Mid(ConvertDate,6,2)  
  daystr=Right(ConvertDate,2)  
  Elseif   strLen=9   Then  
  '//2005-7-23  
  If   Mid(ConvertDate,7,1)="-"   Then  
  monthstr=Mid(ConvertDate,6,1)  
  daystr=Right(ConvertDate,2)  
  '//2005-12-3  
  Else  
  monthstr=Mid(ConvertDate,6,2)  
  daystr=Right(ConvertDate,1)  
  End   If  
  '//2005-1-8  
  Else  
  monthstr=Mid(ConvertDate,6,1)  
  daystr=Right(ConvertDate,1)  
  End   If  
   
  Dim   monthstrToEn  
  Select   Case   monthstr  
  Case   "1"  
  monthstrToEn="January"  
  Case   "2"  
  monthstrToEn="February"  
  Case   "3"  
  monthstrToEn="March"  
  Case   "4"  
  monthstrToEn="April"  
  Case   "5"  
  monthstrToEn="May"  
  Case   "6"  
  monthstrToEn="June"  
  Case   "7"  
  monthstrToEn="July"  
  Case   "8"  
  monthstrToEn="August"  
  Case   "9"  
  monthstrToEn="September"  
  Case   "10"  
  monthstrToEn="October"  
  Case   "11"  
  monthstrToEn="November"  
  Case   "12"  
  monthstrToEn="December"  
  End   Select  
   
  DCF=monthstrToEn&","&daystr&","&yearstr  
   
  End   Function  
  %>  
  Top

7 楼brothercat(猫猫 ^_^)回复于 2005-08-22 16:41:30 得分 20

好了,这个最完美:)  
  <%  
  Dim   datestr1   'as   String  
  datestr1=Now()  
  Response.Write   DCF(datestr1)  
   
  Response.End  
  %>  
  <%  
  '////////心晴——转换成英文日期格式通用函数/////////  
  '/////////Designed   By   Leon   2005年8月22日//////////  
  Function   DCF(datestr)  
  Dim   ConvertDate  
  ConvertDate=FormatDateTime(datestr,vbShortDate)  
   
  Dim   strLen  
  strLen=Len(ConvertDate)  
   
  Dim   yearstr  
  yearstr=Left(ConvertDate,4)  
   
  Dim   monthnum,daystr  
  '//2005-12-11  
  If   strLen=10   Then  
  monthnum=Mid(ConvertDate,6,2)  
  daystr=Right(ConvertDate,2)  
  Elseif   strLen=9   Then  
  '//2005-7-23  
  If   Mid(ConvertDate,7,1)="-"   Then  
  monthnum=Mid(ConvertDate,6,1)  
  daystr=Right(ConvertDate,2)  
  '//2005-12-3  
  Else  
  monthnum=Mid(ConvertDate,6,2)  
  daystr=Right(ConvertDate,1)  
  End   If  
  '//2005-1-8  
  Else  
  monthnum=Mid(ConvertDate,6,1)  
  daystr=Right(ConvertDate,1)  
  End   If  
   
  Dim   monthstr  
  Select   Case   monthnum  
  Case   "1"  
  monthstr="January"  
  Case   "2"  
  monthstr="February"  
  Case   "3"  
  monthstr="March"  
  Case   "4"  
  monthstr="April"  
  Case   "5"  
  monthstr="May"  
  Case   "6"  
  monthstr="June"  
  Case   "7"  
  monthstr="July"  
  Case   "8"  
  monthstr="August"  
  Case   "9"  
  monthstr="September"  
  Case   "10"  
  monthstr="October"  
  Case   "11"  
  monthstr="November"  
  Case   "12"  
  monthstr="December"  
  End   Select  
   
  Dim   Y,M,D  
  Y=Int(yearstr)  
   
  If   monthnum="1"   Then  
  M=13  
  Elseif   monthnum="2"   Then  
  M=14  
  Else  
  M=Int(monthnum)  
  End   If  
   
  If   Left(daystr,1)="0"   Then  
  D=Int(Right(daystr,1))  
  Else  
  D=Int(daystr)  
  End   If  
   
  Dim   weeknum  
  weeknum=(D+2*M+3*(M+1)/5+Y+Y/4-Y/100+Y/400)   Mod   7+1  
   
  Dim   weekstr  
  Select   Case   weeknum  
  Case   1  
  weekstr="Sunday"  
  Case   2  
  weekstr="Monday"  
  Case   3  
  weekstr="Tuesday"  
  Case   4  
  weekstr="Wednesday"  
  Case   5  
  weekstr="Thursday"  
  Case   6  
  weekstr="Friday"  
  Case   7  
  weekstr="Saturday"  
  End   Select  
   
  DCF=weekstr&","&monthstr&","&daystr&","&yearstr  
   
  End   Function  
  %>Top

相关问题

  • 日期字段显示格式问题。
  • DataGrid中日期显示格式问题?
  • 日期的格式化显示
  • DataGrid格式化日期显示问题
  • 时间格式按日期显示
  • 日期格式的显示样式???
  • 如何让日期显示为长日期格式
  • 怎么显示当日的日期,日期格式为20050120
  • 日期格式
  • 怎样在DBGrid中使日期以长格式显示?

关键词

  • 格式化
  • 数值
  • 指示
  • date
  • 表达式
  • namedformat
  • 日期
  • formatdatetime
  • august04
  • vbgeneraldate

得分解答快速导航

  • 帖主:melted
  • brothercat

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo