Link to home
Start Free TrialLog in
Avatar of fksolutions
fksolutions

asked on

ASP date from db - 2 months

I am a beginner at ASP, I need help with a date function.
I am working with an old ASP VB script.

I have a date in DB.

<%=rs("start")%> (my date in db for example: 2012-09-01)

Fisr question:
How do I write a date 2 months back? - 2012-07-01

And second question:
How do I write same as question one but instead of full date just show 07 or Juli(month name).
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fksolutions
fksolutions

ASKER

 <% 
 startdaterorligt = rs2("start")
 dateadd("m", -2, startdaterorligt) %>

Open in new window


gets error
Microsoft VBScript compilation error '800a0414'

Cannot use parentheses when calling a Sub

/include/johan201208.asp, line 538

dateadd("m", -2, startdaterorligt)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is your recordset really called, rs2("start") otherwise it will be counted as a function.  You can use rs2.Fields.Item("start").Value to be sure.  

You need to make sure your recordset is created in your include file or before the code where you insert the include file on the main page.
You missed that DateAdd returns a value, so use it like this

<% 
 startdaterorligt = rs2("start")
SomeThing = DateAdd("m", -2, startdaterorligt)
%>

Open in new window

GH