asp 日期操作

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  <% Response.Buffer=True 
 Session.CodePage=65001
 Server.ScriptTimeOut = 90 
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>asp 日期操作 涂聚文</title>
<%
 dim tonow,setnow,cd,disday
 
 tonow=Now()
 
 
%>
</head>

<body>
<%
setnow=dateadd("m",-1,year(tonow)&"-"&month(tonow)&"-1")
%>
上个月第一天:<%=setnow%><br/>  
<%
setnow=dateadd("d",-1,year(tonow)&"-"&month(tonow)&"-1")
%>
上个月最后一天:<%=setnow%><br/>  
<%
setnow=year(tonow)&"-"&month(tonow)&"-1"
%>

本月第一天:<%=setnow%><br/>  
<%
setnow=dateadd("d",-1,dateadd("m",1,year(tonow)&"-"&month(tonow)&"-1"))
%>

本月最后一天:<%=setnow%><br/>  
<%
setnow=dateadd("m",1,year(tonow)&"-"&month(tonow)&"-01")
%>

下个月第一天:<%=setnow%><br/>  
<%
setnow=dateadd("d",-1,dateadd("m",2,year(tonow)&"-"&month(tonow)&"-01"))
%>
下个月最后一天:<%=setnow%><br/>


<%
setnow=dateadd("m",-2,year(tonow)&"-"&month(tonow)&"-01")
%>
下二个月第一天:<%=setnow%><br/>  
<%
setnow=dateadd("d",-1,dateadd("m",3,year(tonow)&"-"&month(tonow)&"-01"))
%>
下二个月最后一天:<%=setnow%><br/> 
<%
setnow="2013-10-11"
cd=DATEDIFF("d",tonow,setnow)

%>
两个日期差(天):<%=cd%> <br/> 
<%
 disday=dateadd("d",-1,dateadd("m",3,year(setnow)&"-"&month(setnow)&"-01"))
%>
<%=setnow%>下二个月最后一天:<%=disday%><br/> 
</body>

</html>

 

你可能感兴趣的:(asp)