473,803 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Fiscal Date problem Date(), DateDiff(), DatePart()??

Hi,

My company runs on a fiscal calendar that starts on the first monday in
July, and is based on a 13 week quarter (4 weeks, 4 weeks, 5 weeks).
What I need, is a way of relating Date() to the actual fiscal month
(e.g. today is 01/07/05, and is the last day in June in our fiscal
calendar).

I tried many methods, and had hoped that DatePart() with the 'ww' flag
and DatePart() with the 'w' flag (to choose the first monday in July,
and then work our the weeks based on that), however it appears to be
only relative to a January start, and not July.

I could probably do a work around by hardcoding some dates, but that
will only work for a given year, and will require changes each year.

Any help would be appreciated.

Cheers,
Haydn

Nov 13 '05 #1
3 6941

It's been a while since I've had to work with Fiscal Dates, but there
is a KnowledgeBase artical on using Fiscal Dates in Access. Sadly, I
an't remember the number of it at the moment. Try searching for it at
http://support.microsoft.com/

ha************* @yahoo.com.au wrote:
My company runs on a fiscal calendar that starts on the first monday in
July, and is based on a 13 week quarter (4 weeks, 4 weeks, 5 weeks).
What I need, is a way of relating Date() to the actual fiscal month
(e.g. today is 01/07/05, and is the last day in June in our fiscal
calendar).
I tried many methods, and had hoped that DatePart() with the 'ww' flag
and DatePart() with the 'w' flag (to choose the first monday in July,
and then work our the weeks based on that), however it appears to be
only relative to a January start, and not July.
I could probably do a work around by hardcoding some dates, but that
will only work for a given year, and will require changes each year.


Nov 13 '05 #2
Hmm... step 1. get the first monday in july of the given year....
something like this:

Public Function FirstMonday(ByV al intMonth As Integer, intYear As
Integer) As Date
Dim dtDate As Date
dtDate = DateSerial(intY ear, intMonth, 1)
Do Until Weekday(dtDate) = vbMonday
dtDate = DateAdd("d", 1, dtDate)
Loop
FirstMonday = dtDate

End Function
Then do all your datediff functions from that. Umm... month# would be
something like take the weeknumber, add 3, and integer divide by 4.
= (intWeekNo+3)\4
and that's the month, right?

Hard coding? Nah! The above function should give you the first monday
of any month of any year. Just plug in the month/year combination you
want...

Child's play! You just gotta get a bit used to VB, that's all.

Nov 13 '05 #3

pi********@hotm ail.com wrote:
Hmm... step 1. get the first monday in july of the given year....
something like this:

Public Function FirstMonday(ByV al intMonth As Integer, intYear As
Integer) As Date
Dim dtDate As Date
dtDate = DateSerial(intY ear, intMonth, 1)
Do Until Weekday(dtDate) = vbMonday
dtDate = DateAdd("d", 1, dtDate)
Loop
FirstMonday = dtDate

End Function


This can be calculated directly without looping.

New version of NthXDay function:

Public Function NthXDay(N As Integer, D As Integer, dtD As Date) _
As Integer
NthXDay = (7 - WeekDay(DateSer ial(Year(dtD), Month(dtD), 1)) _
+ D) Mod 7 + 1 + (N - 1) * 7
End Function

This one-line function has been adjusted to use the default
firstdayofweek value for the WeekDay function.

Usage:

First Monday in July 2005:

NthXDay(1, vbMonday, #7/1/05#) ==> 4

BTW, I'm getting close to being finished with the documentation for the
Easter function solved by C. F. Gauss. I'll probably be done in about
two weeks. I have a few loose ends to tidy up and a few details left
to understand fully. Also, I'm looking into the possibility of a
simpler computation given that much of Gauss' method is for getting the
Sunday following a given date which can be done fairly easily using the
WeekDay function. Part of the bonus of doing all this additional
investigation is that I should be able to calculate moon phases and
other holidays that are based on lunar months. No holiday tables for
me!

James A. Fortune

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7831
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's the issue. I hope I've included all relevant information. On a form, I have a DateTimePicker with the following
1
2474
by: Tony Ciconte | last post by:
I am using Acc97 and trying to get the following instruction to work in the OnOpen event of a report: DLookup("", "tblTempRevenueByFY", DatePart("m", ) = 1) The table tblTempRevenueByFY exists, with data, as do the fields "GiftAmt" and "GiftDate". However, when I try to preview the report, I get 2465 error that says it cannot find the field "GiftDate". I have tried every combination of quotes, double-quotes, parentheses, etc.
36
2477
by: MLH | last post by:
Does Date = Date + 1 mean Date Statement equals Date Function plus 1? And if the answer is Yes, how much actual time is being added to the date function in this assignment?
1
5554
by: Me | last post by:
I need to get the past 5(x) months for certaing calculations. What I have is listed below: ######################################## my $year, $month_str, $month_int; foreach my $count (1..5) { $year = `date --date '$count months ago' +"%Y"`; chop($year);
2
7263
by: Dinesh | last post by:
Hi experts, I am working on SQL server 2005 reporting services and i am getting a problem in writting a query. Situation is given below. There is one table in database Named Child Now i have to find the All childrens whoes Age is 13 years Base on
2
8879
by: ankitmathur | last post by:
Hi Friends, I have been trying to use this query to get all records that will expire within the next 30 days from the current date. While I am getting records with the same query what is bothering is I'm also getting records for the days past by. Select AccountId, ExpiryDate, DATEDIFF(DAY,GETDATE(),ExpiryDate) as DaysLeft From Usr_Accounts WHERE Status='Active' AND DATEDIFF(DAY,GETDATE(),ExpiryDate) < 31
1
1402
by: dkyadav80 | last post by:
hi sir, I have following problem: code goes here: {code] 1. <html> 2. <body>
10
2002
by: viki1967 | last post by:
Help with check date and hours Hi all. I have this form: <html> <head>
7
2066
by: colintis | last post by:
I want to write a code that can automatically change the year of a date value after getting into a new financial year (e.g. October). Here's only the concept of what I had in mind Dim finYear as Date Dim intYear as Integer finYear = DateValue("01/10/2000") intYear = Year(Date) 'Below will be in words instead of code
0
9700
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, 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...
0
10546
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9121
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, 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...
0
6841
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();...
0
5498
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...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
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...

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.