Time Base Flagging with ASP datetime function
Time Base Flagging with ASP datetime function
<%
strStartTime1 = "13/02/2012 05:10:00"
strEndTime1 = "16/02/2012 05:11:00"
strDiff1 = DateDiff("n",strStartTime1,strEndTime1)
'response.write strDiff1
'response.write "<hr>"
if strDiff1 >=0 then
%>
<center> <h3>"ORDERS PLACED NOW FOR VALENTINE'S DAY - 14TH FEBRUARY WILL BE DELIVERED LATEST BY 15TH FEBRUARY"</h3> </center>
<%
else
end if
%>
Dynamic Arrays
Dynamic arrays come in handy when you aren’t sure how many items your array will hold. To create a dynamic array you should use the Dim statement along with the array’s name, without specifying upper bound:
<% Dim arrCars arrCars = Array() %>
In order to use this array you need to use the ReDim statement to define the array’s upper bound:
<% Dim arrCars arrCars = Array() Redim arrCars(27) %>
If in future you need to resize this array you should use the Redim statement again. Be very careful with the ReDim statement. When you use the ReDim statement you lose all elements of the array. Using the keyword PRESERVE in conjunction with the ReDim statement will keep the array we already have and increase the size:
<% Dim arrCars arrCars = Array() Redim arrCars(27) Redim PRESERVE arrCars(52) %>
Static Arrays
<%@ LANGUAGE="VBSCRIPT" %> <% 'Use the Dim statement along with the array name 'to create a static VBScript array 'The number in parentheses defines the array’s upper bound Dim arrCars(4) arrCars(0)="BMW" arrCars(1)="Mercedes" arrCars(2)="Audi" arrCars(3)="Bentley" arrCars(4)="Mini" 'create a loop moving through the array 'and print out the values For i=0 to 4 response.write arrCars(i) & "<br>" Next 'move on to the next value of i %>
Here is another way to define the array in VBScript:
<%
'we use the VBScript Array function along with a Dim statement
'to create and populate our array
Dim arrCars
arrCars = Array("BMW","Mercedes","Audi","Bentley","Mini") 'each element must be separated by a comma
'again we could loop through the array and print out the values
For i=0 to 4
response.write arrCars(i) & "<br>"
Next
%>
Selected Characters from VBA’s Character Code Set
|
Format Medium Date
The FormatMediumDate function returns mm/dd/yyyy, unlike (FormatDateTime(Now(),2) which only returns mm/dd/yy.
The FormatMediumDate function returns mm/dd/yyyy, unlike (FormatDateTime(Now(),2) which only returns mm/dd/yy.
Syntax:
mediumdate = FormatMediumDate(datevar)
Example Usage:
<% = FormatMediumDate(rs("date")) %>
ASP Source Code:
<%
Function FormatMediumDate(DateValue)
Dim strYYYY
Dim strMM
Dim strDD
strYYYY = CStr(DatePart("yyyy", DateValue))
strMM = CStr(DatePart("m", DateValue))
If Len(strMM) = 1 Then strMM = "0" & strMM
strDD = CStr(DatePart("d", DateValue))
If Len(strDD) = 1 Then strDD = "0" & strDD
FormatMediumDate = strMM & "/" & strDD & "/" & strYYYY
End Function
%>
Access Secure files on local machine or the network drives
<%
'####### Created By Pranav Ajgaonkar
'####### 12th July 2010
'####### PSCS E-BUSINESS
'####### WWW.PSCSGLOBAL.COM
'####### Access Secure files on local machine or the network drives
'####### pranav.aj@pscsglobal.com
'###### Validate User Session
'If session("loggedIn") = True Then
'###### Demo Version
'###### Enter your File Name
'###### In the Live Version develop a function to identify the File-Name based on the User Session EMP Code
'###### Place This File in C:\
testingFilename = "testfile.pdf"
'###### File Path (Local Drive or Network Drive)
strFilePath = "C:\" & testingFilename ' & request.querystring("filename")
'#####################################
'#####################################
'######### #########
'######### Do Not Edit Below #########
'######### #########
'#####################################
'#####################################
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFilePath) Then
Set objFile = objFSO.GetFile(strFilePath)
intFileSize = objFile.Size
Set objFile = Nothing
strFileName = testingFilename ' request.querystring("filename")
strFileName = replace(testingFilename," ","-") 'replace(request.querystring("filename")," ","-")
Response.AddHeader "Content-Disposition","attachment; filename=" & strFileName
Response.ContentType = "application/x-msdownload"
Response.AddHeader "Content-Length", intFileSize
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1 'adTypeBinary
objStream.LoadFromFile strFilePath
Do While Not objStream.EOS And Response.IsClientConnected
Response.BinaryWrite objStream.Read(1024)
Response.Flush()
Loop
objStream.Close
Set objStream = Nothing
Else
Response.write "Error finding file."
End if
Set objFSO = Nothing
'End If
%>
