473,372 Members | 1,240 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,372 software developers and data experts.

every 2 week function

There are probably a dozen really obnoxious ways to solve this :
But I am trusting someone has a better idea than mine.

The method calls below will tell me by the result= 0 if my program
has reached another 2 week cycle. But once the year rolls over..
- Seems like I need to get the days not from year but the days
from the beginning of time...( although I am not sure how to get that ...)
or resort to some other roll over techniques.
int update = 0;
int iresult;

DateTime theday = DateTime.Now;
int dayOfYear = theday.DayOfYear;

DateTime SeedDate = Convert.ToDateTime("1/23/06");
int seedDayOfYear = SeedDate.DayOfYear;

update = Math.DivRem(dayOfYear-seedDayOfYear, 14, out iresult);

Thanks
--
Andrew
Feb 7 '06 #1
2 1496
You can get the difference (number of days) between two datetimes by
subtracting them and reading the "TotalDays" property from the resulting
TimeSpan, something like:

DateTime now = DateTime.Now;
DateTime seed = Convert.ToDateTime("2006/01/01");

TimeSpan diff = now - seed;
int result = diff.TotalDays % 14;

hth,
Baileys

andrewcw wrote:
There are probably a dozen really obnoxious ways to solve this :
But I am trusting someone has a better idea than mine.

The method calls below will tell me by the result= 0 if my program
has reached another 2 week cycle. But once the year rolls over..
- Seems like I need to get the days not from year but the days
from the beginning of time...( although I am not sure how to get that ...)
or resort to some other roll over techniques.
int update = 0;
int iresult;

DateTime theday = DateTime.Now;
int dayOfYear = theday.DayOfYear;

DateTime SeedDate = Convert.ToDateTime("1/23/06");
int seedDayOfYear = SeedDate.DayOfYear;

update = Math.DivRem(dayOfYear-seedDayOfYear, 14, out iresult);

Thanks

Feb 7 '06 #2
Thanks that's exactly what I needed to build my function
--
Andrew
"andrewcw" wrote:
There are probably a dozen really obnoxious ways to solve this :
But I am trusting someone has a better idea than mine.

The method calls below will tell me by the result= 0 if my program
has reached another 2 week cycle. But once the year rolls over..
- Seems like I need to get the days not from year but the days
from the beginning of time...( although I am not sure how to get that ...)
or resort to some other roll over techniques.
int update = 0;
int iresult;

DateTime theday = DateTime.Now;
int dayOfYear = theday.DayOfYear;

DateTime SeedDate = Convert.ToDateTime("1/23/06");
int seedDayOfYear = SeedDate.DayOfYear;

update = Math.DivRem(dayOfYear-seedDayOfYear, 14, out iresult);

Thanks
--
Andrew

Feb 7 '06 #3

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

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
4
by: Mark | last post by:
Hi I have been trying to convert the week number to a range of dates that I can use. It should be fairly simple for you guru's out there but for us mere mortals it is beyond our grasp. I know...
0
by: Lee Harr | last post by:
I wrote a function to return the first date of a given week (and a few related functions) : -- return the first date in the given week CREATE or REPLACE FUNCTION week_start(integer, integer)...
14
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity....
18
by: Jen | last post by:
Is it possible (how) to display a new record every week (or day) from a recordset?
6
by: aarklon | last post by:
Hi folks, I found an algorithm for calculating the day of the week here:- http://www.faqs.org/faqs/calendars/faq/part1/index.html in the section titled 2.5 what day of the week was 2 august...
10
by: Jim | last post by:
I'm sure this has been asked before but I can't find any postings. I have a table that has weekly inspections for multiple buildings. What I need to do is break these down by the week of the...
3
by: sbaird | last post by:
Aloha from Hawaii, I'm beating my head on the wall here. I have a recruiting contact managment database I'm trying to create. Managers (there ar 14 of them) have to make a certain number of...
4
by: Vince | last post by:
Given a week Number, how do I calculate the date that for the Monday of that week?
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.