Date format problem
Hi all,
Thanks for all the questions you have answered.I have this code.I want the final dates as mm/dd/yyyy.but am getting only one digit for day and month.This is a very basic question,but i am learning.please help.Thanks.
<%@ Language=VBScript %>
<% Response.Buffer = True %>
<%
Dim freq
freq="222"
d=Now()
d=FormatDateTime(d, 2)
select case freq
Case "0"
begdate=d
Case "1"
end1=DateAdd("d", -1, d)
begdate=Month(end1) & "/" & Day(end1) & "/" & Year(end1)
'Response.write "Daily date of interest" & begdate
case "222"
k=Weekday(CDate(d))
end1=DateAdd("d", -k, d)
begdate=Month(end1) & "/" & Day(end1) & "/" & Year(end1)
beg=DateAdd("d", -(k+6),d)
enddate=Month(beg) & "/" & Day(beg) & "/" & Year(beg)
'Response.write" Beg period is" & begdate
'Response.write" Ending period is" & enddate
case "333"
k=Weekday(CDate(d))
end1=DateAdd("d", -k, d)
begdate=Month(end1) & "/" & Day(end1) & "/" & Year(end1)
beg=DateAdd("d", -(k+13),d)
enddate=Month(beg) & "/" & Day(beg) & "/" & Year(beg)
'Response.write" Beg period is" & begdate
'Response.write" Ending period is" & enddate
case "444"
EndDate = DateSerial(year(date()), month(date()), 0)
BegDate = DateSerial(year(date()), month(date())-1, 1)
'Response.write" Beg period is" & begdate
'Response.write" Ending period is" & enddate
case "555"
EndDate = DateSerial(year(date()), month(date()), 0)
BegDate = DateSerial(year(date()), month(date())-3, 1)
'Response.write" Beg period is" & begdate
'Response.write" Ending period is" & enddate
case "666"
EndDate = DateSerial(year(date()), month(date()), 0)
BegDate = DateSerial(year(date()), month(date())-6, 1)
'Response.write" Beg period is" & begdate
'Response.write" Ending period is" & enddate
case "777"
EndDate = DateSerial(year(date()), month(date()), 0)
BegDate = DateSerial(year(date()), month(date())-12, 1)
'Response.write" Beg period is" & begdate
'Response.write" Ending period is" & enddate
End Select
Response.write "Beg date is" & BegDate & "<br>"
Response.write "End date is" & EndDate
%>
Widad
|