Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / July 2006

Tip: Looking for answers? Try searching our database.

Updating field based Between Dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dlmaley - 28 Jul 2006 14:17 GMT
I want to update sick time accrued to 8 hours when an employee's start date
is between January 2nd and May 1st in the same year as a date entered by a
user. For example, if the date entered by a user is 12/31/2005, and the
employee start date is 1/14/2005, sick time accrued would be updated to 8
hours. If the employee start date is 5/2/2005, the field would not be
updated. If the employee start date is 5/2/2006, the field would not be
updated.

I am currently trying to run this from an update query. The query runs, but
it does not update the records that should be updated. The user enters the
"as of date" in a parameter query that updates the asofdate field in the
Accruals table before this update query is run. I will need to build on this
to add multiple date criteria with different accruals. Here is the SQL.

UPDATE tblAccruals SET tblAccruals.SICKACCRUE = 8
WHERE (((tblAccruals.STARTDATEFT) Between (DatePart("m",[STARTDATEFT])=1 And
DatePart("d",[STARTDATEFT])=2 And
DatePart("yyyy",[STARTDATEFT])=DatePart("yyyy",[asofdate])) And
(DatePart("m",[STARTDATEFT])=5 And DatePart("d",[STARTDATEFT])=1 And
DatePart("yyyy",[STARTDATEFT])=DatePart("yyyy",[asofdate]))));

How do I get this to update the correct records? Thanks for any assistance.

Debby
Jeff L - 28 Jul 2006 15:37 GMT
Try this:

UPDATE tblAccruals SET tblAccruals.SICKACCRUE = 8
WHERE (((tblAccruals.STARTDATEFT) Between "1/2/" & Year([AsOfDate]) And
"5/31/" & Year([AsOfDate])
dlmaley - 31 Jul 2006 16:51 GMT
Awesome, this works. Thanks very much Jeff!

> Try this:
>
> UPDATE tblAccruals SET tblAccruals.SICKACCRUE = 8
> WHERE (((tblAccruals.STARTDATEFT) Between "1/2/" & Year([AsOfDate]) And
> "5/31/" & Year([AsOfDate])
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.