Hi,
I have a query that calculates the sum of branch transfers for the current quarter. Here is my Quarter-to-Date field:
QTD-In: Sum(CCur(IIf([TAT]="TRN" And [INVCDAT] Between DateSerial(Year (Date()),Int((M onth(Date())-1)/3)*3+1,1) And DateSerial(Year (Date()),Int((M onth(Date())-1)/3)*3+4,0),[LISPRI]*[dbo_INIDP]![ORDQTY],0)))
Now, I need to make sure I understand the DateSerials, which I think I do but I'd rather be safe than sorry.
For DateSerial(Year (Date()), Int((Month(Date ())-1)/3)*3+1,1):
-Year(Date()) takes the current year.
- Int((Month(Date ())-1)/3)*3+1 gets the first month of the current quarter. If it's the first quarter it will always be 1. If it's the second quarter it will always be 4. Third quarter will be 7 and fourth quarter will be 10.
- ,1 ) will return the first day of the month.
So the above DateSerial will ALWAYS return the first day of the CURRENT quarter.
For DateSerial(Year (Date()), Int(Month(Date( ))-1/3)*3+4, 0)
-Year(Date()) takes the current year.
- Int((Month(Date ())-1/3)*3+4 gets the first month of the NEXT quarter. If it's the first quarter it will always be 4. If it's the second quarter it will always be 7. Third quarter will be 10 and fourth quarter will be 13.
- , 0) will make the function return the last day of the previous month.
So the above DateSerial will ALWAYS return the last day of the CURRENT quarter.
So is my understanding correct?
Thanks in advance,
Raza
3 2684 FishVal 2,653
Recognized Expert Specialist
DateSerial(Year (Date()), Int((Month(Date ())-1)/3)*3+1,0):
So the above DateSerial will ALWAYS return the last day of the CURRENT quarter.
So is my understanding correct?
Hi, Raza. Pretty looks like your understanding is correct. Nice code logic BTW. :)
Thanks for taking the time to verify that. Better I know now than when i send it off to 9 offices.
nico5038 3,080
Recognized Expert Specialist
Perhaps worthwhile to test or this:
QTD-In: Sum(CCur(IIf([TAT]="TRN" And format([INVCDAT],"yyyyq") = Format(Date()," yyyyq)),[LISPRI]*[dbo_INIDP]![ORDQTY],0)))
Performs as fast as your solution.
Nic;o)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jeremy Wallace |
last post by:
I have some code that uses DateSerial to populate a couple of text boxes on
a form. I was doing some testing this afternoon and found that I get funny
values if the year supplied is 99. 98 works fine. 04 works fine. 1999 works
fine. 100 works fine. But 98 gives a funny value. Anyone have thoughts on
why, or how to re-form the dateserial call to deal with this?
Here's some results from the immediate window:
?(DateSerial(98 , 12+ 1, 1)) -...
|
by: dik mus |
last post by:
Hi,
I connect to a database that only stores the year and weeknumber. But i need
the date of the corresponding monday.
This could be more difficult as one expect because the weekumbers might
change from country to country.
(I am looking for a dutch solution.)
Thanks, dik
|
by: Duppypog |
last post by:
I'm trying to compare a date stored in a database with today's date using an
If statement, but it's not returning true. Example, value in database is
11/5/2003 with today being 11/6/2003. Can someone spot the problem?
Thanks,
Lynnette
Here's the code:
sSQL = "Select PWExpire FROM tblUsers where strUserName = '" & stUser & "'
AND strPassword = '" & hshPW & "'"
|
by: Kenny |
last post by:
I am having issues with the "Date.ToOADate" method in
VB .NET. I understand that in VB6 the function DateSerial
gives an internal representation of the date.
When I use the DateSerial method in VB .Net, dragging the
mouse over to the statement, VB .NET reports the following
"Conversion from 'Date' to "Double' requires calling
the 'Date.ToOAdate' method.
When I tyoe this method in, the syntax checker undelines
|
by: jerry.ranch |
last post by:
I see that DateSerial can be used to "concatenate", in a way, three
fields DateSerial(year, month day) into a date field (if year , month
and date are numeric values). Unfortunately, my Month field is Text
(January, February etc).
What function is used to convert text month to numerical 1-12?
Thanks
Jerry
| |
by: Bill |
last post by:
I have a 200 record database that includes a date/time field,
AnnivDate, for a wedding anniversary. AnnivDate has nulls and some
incorrect year data. I have been creating the Access database using
data imported from an Excel file and the person entering into Excel
only cared about the month and day portion and Excel added the current
year to the field value. I want to produce a report that shows
upcoming anniversaries using a parameter...
|
by: pob |
last post by:
I was all happy because thru some tutelage of others I created this
array to find the newest file in a directory. However, I then
realized its great that I now know the latest file, but I need to know
the name of the file. Unfortunately, I am only passing the date into
the array.
Do I need to create a m-d array ? If so how do I create a 2-d array
where I do not know how many rows I will be looping thru ?
|
by: woooopa |
last post by:
Something like this...
MAX (DateSerial(!,!,!))
|
by: ringer |
last post by:
On a form I have a combo where a month is entered. It shows the month names
in column one, but it is bound to column two where each month's corresponding
number is, ie Jan=1, Feb=2, etc. So selecting April returns 4. Also on the
form I have a text box where a number is entered and used as the date of the
month in the aforementioned combo box.
I pull those numbers (month number from the combo and date number from the
text box) together...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |