I have a timecard logging program in Access97 that I've used for a few
years now. Most of the year it works without problems. But...
Every January, when logging in the December cards, the data entry
person has to start including the year when typing, otherwise the card
is logged as NEXT December.
I started putting together a simple AfterUpdate function to reduce
keying errors, and it basically looks like this:
if [TCDate]>Now() then
[TCDate]=[TCDate]-365
endif
But then I realized that leap years will cause a one-day-off error.
Rather than re-invent the wheel, I'm hoping one of you nice people can
tell me a simpler way to subtract exactly one year from a keyed-in
date. Is there some sort of named function that I can use in place of
the "-365" bit, rather than write a long IF statement to test for
'year is divisible by 4' except when it's divisible by 100, etc.
I'm pretty sure I'll read the responses and slap my forehead, but I
can live with that. :)
Thanks in advance for any help!
Dennis 2 5017
On 10 Feb 2004 07:20:34 -0800, Dennis Kuhn wrote: I have a timecard logging program in Access97 that I've used for a few years now. Most of the year it works without problems. But...
Every January, when logging in the December cards, the data entry person has to start including the year when typing, otherwise the card is logged as NEXT December.
I started putting together a simple AfterUpdate function to reduce keying errors, and it basically looks like this:
if [TCDate]>Now() then [TCDate]=[TCDate]-365 endif
But then I realized that leap years will cause a one-day-off error. Rather than re-invent the wheel, I'm hoping one of you nice people can tell me a simpler way to subtract exactly one year from a keyed-in date. Is there some sort of named function that I can use in place of the "-365" bit, rather than write a long IF statement to test for 'year is divisible by 4' except when it's divisible by 100, etc.
I'm pretty sure I'll read the responses and slap my forehead, but I can live with that. :)
Thanks in advance for any help!
Dennis
Dennis,
Don't slap too hard.. :-)
[TCDate]=DateAdd("yyyy",-1,[TCDate])
See VBA Help for info on DateAdd().
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
fredg <fg******@att.net> wrote in message news:<iw****************************@40tude.net>.. .
Dennis,
Don't slap too hard.. :-)
[TCDate]=DateAdd("yyyy",-1,[TCDate])
See VBA Help for info on DateAdd().
D'oh! [Slap!!]
The worst part is that I _did_ see the DateAdd bit, but after a
cursory glance at the help for it, I assumed it wasn't really what I
was looking for. In actuality, I was only looking for one specific
type of solution, and didn't accept that this was a valid alternative.
Gotta loosen up this old brain of mine...
Oh, thanks very much!
Dennis This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dlx_son |
last post by:
Here is the code so far
<form name="thisform">
<h3>Enter time to add to or subtract from:</h3>
(If not entered, current time will be used)<br>
Day: <input name="d1" alt="Day of month"...
|
by: Alan |
last post by:
Hi everyone! I'm trying to produce a periodic financial report on
projects from various departments. My database is set up with the
tables tblDepartment, tblProjects, tblPeriods, and tblBudgets...
|
by: Generic Usenet Account |
last post by:
As per Google's Usenet archives
http://groups.google.com/googlegroups/archive_announce_20.html], the
first discussion of the Y2K problem on the Usenet was on January 18
1985...
|
by: S. van Beek |
last post by:
Dear reader,
With DatePart() you can subtract the year or the week from a date field
with:
DatePart("yyyy";) for the year
|
by: meltedown |
last post by:
I can't see what I'm doing wrong. I'm subtracting 60*60*24 from a unix
time stamp and the result is 23 hours earlier, not 24.
Start with a unix time stamp:
$unixtime=1144018006;
convert it to...
|
by: Arne Gemsa |
last post by:
Hi,
I want to get a starttime. To get this I have to subtract the runtime from a
unit e.g. 08:40:15 from a date e.g. 2007-03-29 16:48:30. So the starttime is
2007-03-29 08:08:15.
Is there any...
|
by: dan |
last post by:
Am i breaking any rules when I loop dates like
// Determine Memorial Day
intFlag = 0;
memDayHol = new Date (currentYear, 4, 31);
while (intFlag == 0) {
if (memDayHol.getDay() == 1) {intFlag...
|
by: KA NMC |
last post by:
I need help with the syntax below to subtract two years from the current date
select oe_hdr.customer_id
from oe_hdr
where year (oe_hdr.order_date) >= year (getdate()-2 )
Thanks
|
by: KARTHIKEYAN RAMACHANDRAN |
last post by:
Hi,
We are using wince5.0 device running in AU1200 processor @400Mhz.After booting, system time is synchronized with the CMOS clock time while date & year not synchronized.It returns default...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |