473,405 Members | 2,261 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,405 software developers and data experts.

I need help understanding DateSerial()

53
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((Month(Date())-1)/3)*3+1,1) And DateSerial(Year(Date()),Int((Month(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
Oct 5 '07 #1
3 2662
FishVal
2,653 Expert 2GB
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. :)
Oct 5 '07 #2
RZ15
53
Thanks for taking the time to verify that. Better I know now than when i send it off to 9 offices.
Oct 5 '07 #3
nico5038
3,080 Expert 2GB
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)
Oct 6 '07 #4

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

Similar topics

5
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...
3
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...
2
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...
1
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...
5
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...
2
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...
2
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...
1
by: woooopa | last post by:
Something like this... MAX (DateSerial(!,!,!))
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.