Hello,
How to find a last day of the next week (or in next two weeks) using VB.NET?
for example:
01-Feb-2005 = 13-Feb-2005
or
09-May-2005 = 22-May-2005
Any help is greatly appreciated,
Adam 3 1675
"Adam" <ad**@blah.co m> wrote in message
news:y2******** ************@ne ws20.bellglobal .com... How to find a last day of the next week (or in next two weeks) using VB.NET? for example:
01-Feb-2005 = 13-Feb-2005 or 09-May-2005 = 22-May-2005
Any help is greatly appreciated,
I'm sure there are very many ways of doing this - here is one suggestion:
Function EndOfNextWeek (pdtmStart As DateTime) As DateTime
Dim intLastDayOfWee k as Integer = DayOfWeek.Sunda y ' modify as required
Do until pdtmStart.DayOf Week = DayOfWeek.Sunda y
pdtmStart = pdtmStart.AddDa ys(1)
Loop
Return pdtmStart.AddDa ys(7)
End Function
I know you mentioned VB, but here's a C# example.
Basiclly you just need to get the Day of the Week and substract where you're
at in the Day of the Week and pass that to AddDays() (AddDays() accepts
negative numbers) and that'll get you to your start of the week (Sunday).
class Class1
{
static DateTime AheadWeek(DateT ime dt, int numOfWeeks)
{
return(dt.AddDa ys( ( -(Convert.ToInt3 2(dt.DayOfWeek) ) ) + (numOfWeeks *
7) ));
}
[STAThread]
static void Main(string[] args)
{
// Start of this week
DateTime dt = AheadWeek(DateT ime.Now, 0);
// One week ahead of todays date
DateTime dt = AheadWeek(DateT ime.Now, 1);
// Two weeks ahead of todays date
DateTime dt = AheadWeek(DateT ime.Now, 2);
}
}
"Adam" <ad**@blah.co m> wrote in message
news:y2******** ************@ne ws20.bellglobal .com... Hello,
How to find a last day of the next week (or in next two weeks) using VB.NET? for example:
01-Feb-2005 = 13-Feb-2005 or 09-May-2005 = 22-May-2005
Any help is greatly appreciated, Adam
On Mon, 9 May 2005 15:33:29 +0100, "Mark Rae"
<ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote: "Adam" <ad**@blah.co m> wrote in message news:y2******* *************@n ews20.bellgloba l.com...
How to find a last day of the next week (or in next two weeks) using VB.NET? for example:
01-Feb-2005 = 13-Feb-2005 or 09-May-2005 = 22-May-2005
Date.Now.AddDay s(-Date.Now.DayOfW eek).AddDays(14 )
Hope this helps
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: pyuk2005 |
last post by:
The UK Python Conference for 2005 will take place at
the Randolph Hotel, Oxford on 20-23 April 2005.
This is the FINAL CALL for talks. The original deadline
of 26th December has been extended to 6 January, to help
all those folks who were concentrating on the PyCon deadline
of 30th December. Recycled PyCon talks are acceptable.
About the event
|
by: SimonC |
last post by:
I would like to return data from the last 2 weeks of each given month
in Javascript, but in 2 formats.
So, the penultimate week (Monday to Sunday) and the last week (Monday
to ??)
I'm not sure if it can be done, but all help welcomed.
E.g. I have December and would like to see the last 2 weeks.. So this
doesnt mean the last 15 days. What i mean by this is...
|
by: Professor Frink |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms application that is going to be
used to extract data from a legacy system (VSAM based mainframe file
structure), and output data in pipe-delimited record layouts, multiple record
types per file, one file per chosen client. I have been working on...
|
by: Tor Erik Sønvisen |
last post by:
Hi
I need to browse the socket-module source-code. I believe it's contained in
the file socketmodule.c, but I can't locate this file... Where should I
look?
regards tores
|
by: Hadi |
last post by:
Hello,
I have to DateTime structure, how do I calculate if date A is on the same
week with date B or last week of date B?
Thanks,
Hadi
| |
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) RETURNS date AS '
DECLARE
pyear ALIAS FOR $1;
pweek ALIAS FOR $2;
|
by: amanda27 |
last post by:
I have a database that we use in our department for the status of our projects. In the form when you pick a project from the dropdown list I have a subform that pulls the data entered for the following week. I was able to do this by having when they input data it automatically pulls the date for week ending by this: =DateAdd("d",6-Weekday(Date()),Date()),
so therefore to see previous weeks data the subform date field has this:...
|
by: Charlotte |
last post by:
Hi,
is it possible to determine the first and the last day of a week (with
classic ASP)
nu = "06/01/2008"
week = (DatePart("ww",nu))
firstday = dateadd("d",(-datepart("w",date())),nu)
lastday = dateadd("d",(7-datepart("w",date())),nu)
|
by: marlberg |
last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc
Language: C#, ASP.NET
Pre-compiled Libraries: Enterprise Library 3.0 full
I have a requirement to implement in and display in C# and ASP.NET a DataGrid with Updatable rows based on a date retrieved from a data table in SQL Server. Below is the design algorithm.
1. Retrieve the Max(rundate) From MyDataTable
2. If the current month -1 = rundate .month from step 1 then
2a. ...
|
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: 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...
|
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: 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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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...
| |