1. Date and time
<html>
<body>
Today's date is: <%response.write(date())%>.
<br>
The server's local time is: <%response.write(time())%>.
</body>
</html>
2. Get the name of a day
<html>
<body>
<p>
VBScripts' function <b>WeekdayName</b> is used to get a weekday:
</p>
<%
response.Write(WeekDayName(1))
response.Write("<br>")
response.Write(WeekDayName(2))
%>
<p>Abbreviated name of a weekday:</p>
<%
response.Write(WeekDayName(1,true))
response.Write("<br>")
response.Write(WeekDayName(2,true))
%>
<p>Current weekday:</p>
<%
response.Write(WeekdayName(weekday(date)))
response.Write("<br>")
response.Write(WeekdayName(weekday(date), true))
%>
</body>
</html>
3. Get the name of a month
<html>
<body>
<p>VBScripts' function <b>MonthName</b> is used to get a month:</p>
<%
response.Write(MonthName(1))
response.Write("<br>")
response.Write(MonthName(2))
%>
<p>Abbreviated name of a month:</p>
<%
response.Write(MonthName(1,true))
response.Write("<br>")
response.Write(MonthName(2,true))
%>
<p>Current month:</p>
<%
response.Write(MonthName(month(date)))
response.Write("<br>")
response.Write(MonthName(month(date), true))
%>
</body>
</html>
4. Get todays' day and month
<html>
<body>
Today it is
<%response.write(WeekdayName(weekday(date)))%>,
<br>
and the month is
<%response.write(MonthName(month(date)))%>
</body>
</html>
5. Countdown to year 3000
<html>
<body>
<p>Countdown to year 3000:</p>
<p>
<%millennium=cdate("1/1/3000 00:00:00")%>
It is
<%response.write(DateDiff("yyyy", Now(), millennium))%>
years to year 3000!
<br>
It is
<%response.write(DateDiff("m", Now(), millennium))%>
months to year 3000!
<br>
It is
<%response.write(DateDiff("ww", Now(), millennium))%>
weeks to year 3000!
<br>
It is
<%response.write(DateDiff("d", Now(), millennium))%>
days to year 3000!
<br>
It is
<%response.write(DateDiff("h", Now(), millennium))%>
hours to year 3000!
<br>
It is
<%response.write(DateDiff("n", Now(), millennium))%>
minutes to year 3000!
<br>
It is
<%response.write(DateDiff("s", Now(), millennium))%>
seconds to year 3000!
</p>
</body>
</html>
6. Calculate the day which is n days from today
<html>
<body>
<%
response.write(DateAdd("d",30,Date()))
%>
<p>
This example uses <b>DateAdd</b> to calculate a date 30 days from today.
</p>
<p>
Syntax for DateAdd: DateAdd(interval,number,date).
</p>
<%
response.write(DateAdd("d",10,Date()))
%>
<p>
This example uses <b>DateAdd</b> to calculate a date 10 days from today.
</p>
<p>
Syntax for DateAdd: DateAdd(interval,number,date).
</p>
</body>
</html>
7. Format date and time
<html>
<body>
<%
response.write(FormatDateTime(date(),vbgeneraldate))
response.write("<br>")
response.write(FormatDateTime(date(),vblongdate))
response.write("<br>")
response.write(FormatDateTime(date(),vbshortdate))
response.write("<br>")
response.write(FormatDateTime(now(),vblongtime))
response.write("<br>")
response.write(FormatDateTime(now(),vbshorttime))
%>
<p>
Syntax for FormatDateTime: FormatDateTime(date,namedformat).
</p>
</body>
</html>
8. Is this a date?
<html>
<body>
<%
somedate="10/40/11"
response.write(IsDate(somedate))
response.write("<br>")
somedate="18/30/99"
response.write(IsDate(somedate))
response.write("<br>")
somedate="10/30/99"
response.write(IsDate(somedate))
%>
</body>
</html>
'프로그램 > ASP' 카테고리의 다른 글
[ASP] DB 예제 : 데이터 여러 개 출력하기 (0) | 2021.03.09 |
---|---|
[ASP] 문자열 함수, 숫자 함수 실습 (0) | 2021.03.09 |
[ASP] 레코드 이동하기 (MoveNext, MovePrevious, MoveFirst, MoveLast) (0) | 2021.03.09 |
[ASP] getRows()를 이용하여 필드 길이와 로우 길이 구하기 (0) | 2021.03.09 |
[ASP] If문, For문, Do While문 (0) | 2021.03.09 |