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

Date Calculation

Hi: Can any one please tell me how to i calculate the next month
starting day and next month ending date. For example if this is january
then i need the next month that is february starting day and february
ending day. I need to calculate the date in that way given below, I
mean without query. Below method is i use it to calculate the todays
date and the end of the day.

MonthLastDay = Empty
dFirstDayNextMonth = DateSerial(CInt(Format(dCurrDate, "yyyy")),
CInt(Format(dCurrDate, "mm")) + 1, 1)
MonthLastDay = DateAdd("d", -1, dFirstDayNextMonth)

Thanks,
Anna.

Jan 22 '07 #1
4 2468
co*********@gmail.com wrote on 22 jan 2007 in
microsoft.public.inetserver.asp.general:
Hi: Can any one please tell me how to i calculate the next month
starting day and next month ending date. For example if this is january
then i need the next month that is february starting day and february
ending day. I need to calculate the date in that way given below, I
mean without query. Below method is i use it to calculate the todays
date and the end of the day.

MonthLastDay = Empty
dFirstDayNextMonth = DateSerial(CInt(Format(dCurrDate, "yyyy")),
CInt(Format(dCurrDate, "mm")) + 1, 1)
MonthLastDay = DateAdd("d", -1, dFirstDayNextMonth)
======== vbscript

today = Date()
curYear = Year(today)
nextMonth = Month(DateAdd("m", 1, today))
nextNextMonth = Month(DateAdd("m", 2, today))

firstDayNextMonth = _
DateSerial(curYear, nextMonth, 1)

lastDayNextMonth = _
DateAdd("d",-1,DateSerial(curYear,nextNextMonth,1))

=====================


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 22 '07 #2
Evertjan. wrote on 22 jan 2007 in microsoft.public.inetserver.asp.general:
today = Date()
curYear = Year(today)
nextMonth = Month(DateAdd("m", 1, today))
nextNextMonth = Month(DateAdd("m", 2, today))

firstDayNextMonth = _
DateSerial(curYear, nextMonth, 1)

lastDayNextMonth = _
DateAdd("d",-1,DateSerial(curYear,nextNextMonth,1))
Sorry, that was wrong, too quick with the "send" button.

Try [vbscript]:

===============

today = Date()

d = DateAdd("m", 1, today)
d = DateSerial(year(d), month(d), 1)
firstDayNextMonth = d
d = DateAdd("m", 2, today)
d = DateSerial(year(d), month(d), 1)
lastDayNextMonth = DateAdd("d", -1, d)

===============

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 22 '07 #3
Evertjan. wrote:
d = DateAdd("m", 2, today)
d = DateSerial(year(d), month(d), 1)
lastDayNextMonth = DateAdd("d", -1, d)
You can even simplify this further:

d = DateAdd("m", 2, today)
lastDayNextMonth = DateSerial(year(d), month(d), -1)

This is identical to the JSCript behavior:

var D = new Date()
lastDayNextMonth = new Date(D.getFullYear(),D.getMonth()+2,-1)
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jan 25 '07 #4
Dave Anderson wrote on 25 jan 2007 in
microsoft.public.inetserver.asp.general:
Evertjan. wrote:
>d = DateAdd("m", 2, today)
d = DateSerial(year(d), month(d), 1)
lastDayNextMonth = DateAdd("d", -1, d)

You can even simplify this further:

d = DateAdd("m", 2, today)
lastDayNextMonth = DateSerial(year(d), month(d), -1)
I was not sure, and did not test. ;-(
This is identical to the JSCript behavior:

var D = new Date()
lastDayNextMonth = new Date(D.getFullYear(),D.getMonth()+2,-1)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 25 '07 #5

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

Similar topics

4
by: Manny Chohan | last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp? Thanks manny
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
1
by: mene | last post by:
I have a field that contains date information, and sometimes time information as well. I would like to be able to take that date and do a calculation on it. Here are some examples of what is in...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
3
by: Lindie | last post by:
We need to track how often a book has been loaned. We enter the dates and need an automatic calculation how often in the preceeding 12 months it has been taken out. box 1: today's date box 2:...
2
by: smcgrath via AccessMonster.com | last post by:
I have a table listing accounts with a closed date - our Trial balance drops the account after 7 days but our database keeps the record forever - How do I calculate the end of month less 7 days so...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
1
by: c8tz | last post by:
This is a query I have created that picks up the top 3 dates for this data (for example) : Tree Pos2 Date 1 15 23/08/2005 1 20 12/02/2006 1 32 15/10/2006 ...
6
by: krishnakant Mane | last post by:
hello, I am strangely confused with a date calculation problem. the point is that I want to calculate difference in two dates in days. there are two aspects to this problem. firstly, I can't get...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
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...
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...
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
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,...

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.