473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

best Date functions to get specific date periods like YTD as of yesterday, Last YTD

I have a form that I want default dates to appear when opened. I need YTD as of yesterday, YTD last year as of yesterday last year, Last Month as of the same day as yesterday last month, and this month last year with the same date as yesterday last year. I need the begining value of the date field as well as the ending dates for each of the date periods. I run reports based on this form often and it would be so nice not to have to type the date value each time and I would be less likely to screw it up.
Dec 29 '14 #1
3 1083
Seth Schrock
2,965 Expert 2GB
I think that your best bet would be to use the DateAdd() function. It allows to you add negative numbers to today's date to get previous dates and it also allows you to specify the interval that you are subtracting. See MS Access DateAdd Function
Dec 29 '14 #2
With the DateAdd function I am able to add or subtract the month or year but not both at the same time. For some date periods I need to to both. Thanks for answering so quickly! I guess I will coninue to try to work it out.
Dec 29 '14 #3
Seth Schrock
2,965 Expert 2GB
Nest the functions together.
Expand|Select|Wrap|Line Numbers
  1. DateAdd("yyyy", -1, DateAdd("d", -1, Date()))
This gives a year from yesterday.
Dec 29 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Franz Steinhaeusler | last post by:
Hello, with following function, i get a human readable date/time format. mtime = time.strftime(self.timeformat ,time.localtime(st.st_mtime)) However is there a simple solution to get a...
15
by: Paul J. Ettl | last post by:
Two questions: I use var date1 = new Date(); to get todays date. But how can I get yesterdays date? Furthermore I use
3
by: Craig Bates | last post by:
Hi Guys I have recently been learning SQL from a book whose examples used the Oracle engine. I have now made an Access database containing information for English Football fixtures. I am using...
2
by: Terry | last post by:
I have a database that I would like to query for a specific date range. I want to create a report based on this query that will pull any records from the last 7 days. Is this possible? Can...
7
by: TDIOwa | last post by:
I have a form that has a specific date on it. I want to open another form that has the Active Control Calendar on it. I want to open this form to the specific date on the first form. I have...
4
by: Russell | last post by:
I have an assignment that I have to complete. I have to write a windows app in C#. Here is the spec: 1/ Date Comparison Build a program that will find the number of days between two dates. You...
5
by: Kiran | last post by:
Hi, Please help on date functions in C#. I would like to know the relevant exampl to retrieve 2 weeks before date from the current date, 1 month before date from the current date and number...
5
by: associates | last post by:
Hi, I need your help with the date. If a date is given (for example the current date), how do i work out in VBA for Access database that it would give me the last day(friday) of the previous week...
5
by: mfputer | last post by:
Does anyone know how to create an “AllDateinperiod” filter with dynamic dates. Autofilter only allows filtering by month and quarters, I want specific date range. I am new at VBA and need some...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.