Zomg Another date question! (PICS Included)
Hey guys,
I've hit a bit of a brick wall, so I'm here asking the guru's of code what to do.
The code below represents three sql queries that are exectuted on button push. One query is for students arriving, they are paid their initial paycheck. Consequently, the code is supposed to recognize which course they're on (of a possible 3 as you can see with the null checks) AND it checks to see if the month clicked (in this case 1/1 or january) is equal to the month they got here. As you can see below, I'm trying to compare months and years only, because this isn't day specific.
This returns nothing... and I have no idea why.
The plot thickens with the next query. I'm trying to use the BETWEEN operator in SQL to get dates between the start dates and grad dates. Unfortunately, it's including the initial month and the final month. I'm not quit sure how to avoid this.
I use null checks in the code above because some students do not have three courses. Anyway, this code is pulling stuff that isn't supposed to be pulled, aka the initial and final months.
Anyways guys, any help would greatly be appreciated. Looking forward to learning from you.
UPDATE: Pictures added so you know what i'm talking about.
Hey guys,
I've hit a bit of a brick wall, so I'm here asking the guru's of code what to do.
The code below represents three sql queries that are exectuted on button push. One query is for students arriving, they are paid their initial paycheck. Consequently, the code is supposed to recognize which course they're on (of a possible 3 as you can see with the null checks) AND it checks to see if the month clicked (in this case 1/1 or january) is equal to the month they got here. As you can see below, I'm trying to compare months and years only, because this isn't day specific.
Code:
Dim janu as string
Dim januyear as string
Dim januinitial as date
Dim strSQL8 as string
Dim strSQL6 as string
janu = "1/1/"
januyear = Text130.value
januinitial = janu & Januyear
janumonthly = janu & Januyear
strSQL8 = "
SELECT Students_Info.firstname, Students_Info.lastname
FROM Students_Info
WHERE ((Year(#" & januinitial & "#) = Year(Students_Info.startONE)
AND Month(#" & januinitial & "#) = Month(Students_Info.startONE));"
This returns nothing... and I have no idea why.
The plot thickens with the next query. I'm trying to use the BETWEEN operator in SQL to get dates between the start dates and grad dates. Unfortunately, it's including the initial month and the final month. I'm not quit sure how to avoid this.
Code:
strSQL6 = "SELECT Students_Info.firstname, Students_Info.lastname
FROM Students_Info
WHERE ((#" & janumonthly & "# BETWEEN Students_Info.startONE AND Students_Info.gradONE) and Students_Info.gradTWO Is Null)
OR ((#" & janumonthly & "# BETWEEN Students_Info.startONE AND Students_Info.gradTWO) and Students_Info.gradTHR Is Null)
OR (#" & janumonthly & "# BETWEEN Students_Info.startONE AND Students_Info.gradTHR);"
I use null checks in the code above because some students do not have three courses. Anyway, this code is pulling stuff that isn't supposed to be pulled, aka the initial and final months.
Anyways guys, any help would greatly be appreciated. Looking forward to learning from you.
UPDATE: Pictures added so you know what i'm talking about.
Attachments
Last edited: