728x90

1. Date - 현재 날짜 구하기

Now - 현재 날짜와 시간 구하기

예제 1 - Response.Write("오늘 날짜 : " & Date)

결과 : 오늘 날짜 : 2005-01-18

예제 2 - 2001/09/07 형식으로 날짜를 출력

Response.Write Year(Date) & "-" & Month(Date) & "-" & Day(Date)

Response.Write " " & putZero(Hour(Now())) &":"& putZero(minute(Now())) &":"& putZero(Second(Now()))

결과 : 2010-05-18 13:52:42

Function putZero(obj)

If CInt(obj) < 10 Then

putZero = "0" & obj

Else

putZero = obj

End If

End Function

DateSerial(2001, 9, 7)

결과 : 2001-09-07

 

2. DateSerial - 특정 날짜 계산해서 날짜값 구하기

예제 1 - 오늘로부터 2달 전 마지막 날을 구하기

SomeDate = DateSerial(Year(Date), Month(Date) - 1, 1 - 1)

 

3. DatePart - 날짜의 특정 부분을 표시할 수 있도록 해준다.

형식 : DatePart(interval, date[, firstdayofweek[, firstdayofyear]])

예제 1 - 원하는 날짜의 ""만 표시

DatePart("m", DateSerial(2001, 9, 13));

 

4. DateAdd - 날짜를 더하는 함수

형식 : DateAdd(interval, number, date)

예제 1 - 오늘로부터 정확히 1년전 그 주의 요일을 구하기

DatePart("w", DateAdd("y", -1, Date))

 

5. DateDiff - 두 날짜의 날 수를 구해하기

예제 1 - 현재 날짜와 SomeDate 사이에 몇 주가 있는지를 구하기

DateDiff("w",Now,SomeDate)

예제 2 - 현재 날짜와 SomeDate 사이에 몇 일이 있는지를 구하기

Dim SomeDate : SomeDate = CDate("2010-10-01")
strDate = DateDiff("d", date, SomeDate)

 

6. weekday - 요일 확인

 

7. weekdayname - 요일명 확인

예제 - currdate = now()
currid = weekday(currdate)
currname = weekdayname(currid)
response.write "today is" & currname

 

8. MonthName - 월명 확인

예제 - currid = Month(currdate)
response.Write MonthName(currid)

728x90

'프로그래밍 > asp' 카테고리의 다른 글

batch 파일 만들기  (0) 2015.04.24
ASP Session 관리  (0) 2012.10.27
ASP 정규 표현식 사용법  (0) 2012.10.04
[ASP] 날짜 형식 함수 FormatDateTime  (0) 2012.08.17
asp내장함수 모음  (0) 2012.06.27

+ Recent posts