I've been working on a website which i'm having problems with and need some help please!!
We have a database with date values and cash amounts ie
22/06/2014 15.00
23/06/2014 15.00
28/06/2014 15.00
etc...
In my html/asp code I have a table which shows the total amount made today, this month and last month, the problem is our month runs from the 11th of the month to the 10th of the next month.
Output
Today this Month Last Month
£15.00 £135.00 £150.00
So the table is showing the correct amount in the correct columns but when the we get to the 11th of the month the value from 'this month' should move into 'last month' column as this is a new month for us.
I have tried everything to make this work, but have failed... hope someone can help me.
Here is my code
<%@ Language=VBScript %>
<html>
<head>
<%
strDate =Date()
thisDay = day(strDate)
refd = strDate+ 1 - thisDay
fdlm = dateadd("m", -1, refd)
fdtm = dateadd("m", 0, refd)
fdpm = dateadd("m", -2, refd)
fdtm = refd
firstday_thismonth = fdlm + 10 '11th of this month
lastday_thismonth = fdtm + 9 '10th of this month
firstday_lastmonth = fdpm + 10 '11th of last month
lastday_lastmonth = fdlm + 9 '10th of last month
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connStr
strSQL = "SELECT cashpay FROM payroll WHERE email = '" & email & "' ORDER BY TempID DESC"
Set rs = conn.Execute(strSQL)
today = rs("cashpay") ' TODAY
strSQL = "SELECT SUM(cashpay) AS thismonth FROM payroll WHERE (date BETWEEN '" & firstday_thismonth & "' AND '" & lastday_thismonth & "')"
Set rs = conn.Execute(strSQL) ' THIS MONTH
thismonth = rs("thismonth")
strSQL = "SELECT SUM(cashpay) AS lastmonth FROM payroll WHERE (date BETWEEN '" & firstday_lastmonth & "' AND '" & lastday_lastmonth & "')"
Set rs = conn.Execute(strSQL)
lastmonth = rs("lastmonth") ' LAST MONTH
%>
</head>
<body>
<table width="450">
<thead>
<tr>
<th></th>
<th align="left">Today</th>
<th align="left">This Month</th>
<th align="left">Last Month</th>
</tr>
</thead>
<tbody>
<tr>
<td>Payment</a></td>
<td align="left">£<%=today%>.00</td>
<td align="left">£<%=thismonth%>.00</td>
<td align="left">£<%=lastmonth%>.00</td>
</tr>
</tbody>
</table>
</body>
</html>
@ALL sorry I might have not made it clear what the problem is.
When I display the table it shows the values in the correct columns for the whole month (1st to the end of the month) and when it's the 1st of a new month then the columns shift to the right.
What I need is when we get to the 11th of the month is for the values to shift to the right. so in the example above if today was the 11th Aug and I displayed the table then 'this month' value of £135.00 would be displayed in 'last month' column and 'this month' value would display all the values from 11th Aug to 10th Sept.