아미(아름다운미소)

[ASP]날짜관련함수 본문

랭귀지/ASP

[ASP]날짜관련함수

유키공 2017. 12. 22. 14:00
- 윤달 체크
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function get_month_lastday(year, mon)
    dim month_day(12)
    month_day(1) = 31
    month_day(2) = 28
    month_day(3) = 31
    month_day(4) = 30
    month_day(5) = 31
    month_day(6) = 30
    month_day(7) = 31
    month_day(8) = 31
    month_day(9) = 30
    month_day(10) = 31
    month_day(11) = 30
    month_day(12) = 31
 
    if mon = 2 and isdate(year & "-" & mon & "29") then
        get_month_lastday = 29
    else
        get_month_lastday = month_day(mon)
    end if
end function
날짜중에 한자리 일 경우 앞에 0 붙이는 함수
1
2
3
4
5
6
7
8
Function DatePZeroCheckWord(CheckValue)
    If Len(trim(CheckValue)) = 1 Then
        CheckValue= "0" & CheckValue
        DatePZeroCheckWord = CheckValue
    Else
        DatePZeroCheckWord = CheckValue
    End If
End Function
날짜 형식 체크
1
2
3
4
5
6
7
8
9
10
11
12
Function CheckDateSpace(CheckValue)
    If (Len(CheckValue) > 0 and Len(CheckValue) < 10 ) or (Len(CheckValue) > 0 and Not(IsDate(CheckValue))) Then
        Response.write "<script language="JavaScript">"
        Response.write "alert('날짜 형식이 잘못되었습니다. 다시 넣어 주세요!');"
        Response.write "history.back();"
        Response.write "</script>"
        Response.End
        CheckDateSpace = ""
    Else
        CheckDateSpace = CheckValue
    End If
End Function
날짜시 - 를 없애는 문자 함수
1
2
3
4
5
6
7
8
Function DateMCheckWord(CheckValue)
    If Len(CheckValue) > 0 Then
        CheckValue=replace(CheckValue, "-" ,"")
        DateMCheckWord = CheckValue
    Else
        DateMCheckWord = ""
    End If
End Function

날짜시 - 를 생성시키는 문자 함수

1
2
3
4
5
6
7
8
Function DatePCheckWord(CheckValue)
    If Len(Trim(CheckValue)) = 8 Then
        CheckValue  = Left(CheckValue,4)&"-"&mid(CheckValue,5,2)&"-"&mid(CheckValue,7)
        DatePCheckWord = CheckValue
    Else
        DatePCheckWord = ""
    End If
End Function

'랭귀지 > ASP' 카테고리의 다른 글

[asp] 유용함수 정리  (0) 2018.01.11
[ASP]마지막 문자열  (0) 2017.12.26
[ASP] 기타함수  (0) 2017.12.22
[ASP] 숫자관련함수  (0) 2017.12.22
[ASP]문자관련함수  (0) 2017.12.22
Comments