Sum of Current Year minus 1 in Two Digits

  • Thread starter Thread starter Telesphore
  • Start date Start date
T

Telesphore

SELECT tblStudents.StudentID, [LastName] & " " & [FirstName] AS StudentName,
tblStudents.Street, tblStudents.City, tblStudents.CP, tblStudents.PermCod,
Format([InscriptionDate],"yy") AS Inscription2Year,
Format([InscriptionDate],"yyyy") AS Inscription4Year, tblStudents.LastName,
tblStudents.FirstName, tblInscriptions.OtherProg, tblInscriptions.BAProg,
tblInscriptions.BPhProg, tblInscriptions.BThProg, tblInscriptions.MDivProg,
tblInscriptions.MThProg, tblInscriptions.CThProg, tblInscriptions.MPhProg,
tblInscriptions.CPhProg, tblInscriptions.CPFProg, tblInscriptions.CSPIProg

FROM tblStudents INNER JOIN tblInscriptions ON tblStudents.StudentID =
tblInscriptions.StudentID

GROUP BY tblStudents.StudentID, [LastName] & " " & [FirstName],
tblStudents.Street, tblStudents.City, tblStudents.CP, tblStudents.PermCod,
Format([InscriptionDate],"yy"), Format([InscriptionDate],"yyyy"),
tblStudents.LastName, tblStudents.FirstName, tblInscriptions.OtherProg,
tblInscriptions.BAProg, tblInscriptions.BPhProg, tblInscriptions.BThProg,
tblInscriptions.MDivProg, tblInscriptions.MThProg, tblInscriptions.CThProg,
tblInscriptions.MPhProg, tblInscriptions.CPhProg, tblInscriptions.CPFProg,
tblInscriptions.CSPIProg

HAVING (((Format([InscriptionDate],"yy"))="04"))

ORDER BY [LastName] & " " & [FirstName];

*******************

In the line before last of this code: <HAVING
(((Format([InscriptionDate],"yy"))="04"))>, I need to make automic the
expression "04". In other word this should be the subtraction of the
(CurrentYear minus 1) with only the two last digits (2005-1=04)

Thank you in advance
 
Thank you very much.
It works

P.S. I replace InscriptionDate by Date()

schasteen said:
This may not be the best way, but it will work.
right(year([InscriptionDate])-1,2)



Telesphore said:
SELECT tblStudents.StudentID, [LastName] & " " & [FirstName] AS
StudentName,
tblStudents.Street, tblStudents.City, tblStudents.CP,
tblStudents.PermCod,
Format([InscriptionDate],"yy") AS Inscription2Year,
Format([InscriptionDate],"yyyy") AS Inscription4Year,
tblStudents.LastName,
tblStudents.FirstName, tblInscriptions.OtherProg, tblInscriptions.BAProg,
tblInscriptions.BPhProg, tblInscriptions.BThProg,
tblInscriptions.MDivProg,
tblInscriptions.MThProg, tblInscriptions.CThProg,
tblInscriptions.MPhProg,
tblInscriptions.CPhProg, tblInscriptions.CPFProg,
tblInscriptions.CSPIProg

FROM tblStudents INNER JOIN tblInscriptions ON tblStudents.StudentID =
tblInscriptions.StudentID

GROUP BY tblStudents.StudentID, [LastName] & " " & [FirstName],
tblStudents.Street, tblStudents.City, tblStudents.CP,
tblStudents.PermCod,
Format([InscriptionDate],"yy"), Format([InscriptionDate],"yyyy"),
tblStudents.LastName, tblStudents.FirstName, tblInscriptions.OtherProg,
tblInscriptions.BAProg, tblInscriptions.BPhProg, tblInscriptions.BThProg,
tblInscriptions.MDivProg, tblInscriptions.MThProg,
tblInscriptions.CThProg,
tblInscriptions.MPhProg, tblInscriptions.CPhProg,
tblInscriptions.CPFProg,
tblInscriptions.CSPIProg

HAVING (((Format([InscriptionDate],"yy"))="04"))

ORDER BY [LastName] & " " & [FirstName];

*******************

In the line before last of this code: <HAVING
(((Format([InscriptionDate],"yy"))="04"))>, I need to make automic the
expression "04". In other word this should be the subtraction of the
(CurrentYear minus 1) with only the two last digits (2005-1=04)

Thank you in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top