[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

function not working on ASP/VB page

I have the following function which works fine on ASP/Javascript page but not on an ASP/VBscript page:

 <% function todayStr() {
var today=new Date()
return today.getMonth()+1+"/"+today.getDate()+"/"+(today.getYear())
}
%>

I would need the syntax for the ASP/Vb page :)
0
Aleks
Asked:
Aleks
2 Solutions
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
are you trying to get todays date in MM/DD/YY format? you can just use the FormatDateTime built in function:

today = FormatDateTime( now, 2 )
0
 
hieloCommented:
...but not on an ASP/VBscript page:
change the definition so that it is enclosed in <script> tags:
<%@language="vbscript"%>
<script language="javascript" runat="server">
function todayStr() {
    var today=new Date()
return today.getMonth()+1+"/"+today.getDate()+"/"+(today.getYear());
} 
</script>
<%
' vbscript code continues here
Dim strToday
strToday=todayStr()

Response.Write(strToday)
%>

Open in new window

0
 
Scott Fell, EE MVEDeveloperCommented:
<%
response.write AddAMonth
%>

<%
function AddAMonth()
AddAMonth=dateadd("m",1,date)
end function
%>
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now