Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default DateSerial function

I would like to calculate rollong calendar from today in the loop.

For example, today is Dec/11/2008 and I need to get all informaiton 12
months before today. (from Dec/11/2007 to Dec/11/2008).

I just wonder can DateSerila do the job.

For example, DateSerial(MyYear, MyMonth - i, MyDay)

Will DateSerial changed the year if the month is minus number?

Your information is great appreciated,



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default DateSerial function

Are you attempting to construct a loop that will iterate through each day of
the previous 12 months? If so, you can do that directly in the For statement
of your For..Next loop. Consider this (and notice that D is declared as
Date)...

Sub Test()
Dim D As Date
For D = DateAdd("m", -12, Date) To Date
Debug.Print D
Next
End Sub

The above code will print the date for each day for the previous year...
just replace it with the code you actually want to operate on those days.

--
Rick (MVP - Excel)


"inungh" wrote in message
...
I would like to calculate rollong calendar from today in the loop.

For example, today is Dec/11/2008 and I need to get all informaiton 12
months before today. (from Dec/11/2007 to Dec/11/2008).

I just wonder can DateSerila do the job.

For example, DateSerial(MyYear, MyMonth - i, MyDay)

Will DateSerial changed the year if the month is minus number?

Your information is great appreciated,




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default DateSerial function

And to answer your question directly, yes, DateSerial will properly handle
the year when the month goes negative.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Are you attempting to construct a loop that will iterate through each day
of the previous 12 months? If so, you can do that directly in the For
statement of your For..Next loop. Consider this (and notice that D is
declared as Date)...

Sub Test()
Dim D As Date
For D = DateAdd("m", -12, Date) To Date
Debug.Print D
Next
End Sub

The above code will print the date for each day for the previous year...
just replace it with the code you actually want to operate on those days.

--
Rick (MVP - Excel)


"inungh" wrote in message
...
I would like to calculate rollong calendar from today in the loop.

For example, today is Dec/11/2008 and I need to get all informaiton 12
months before today. (from Dec/11/2007 to Dec/11/2008).

I just wonder can DateSerila do the job.

For example, DateSerial(MyYear, MyMonth - i, MyDay)

Will DateSerial changed the year if the month is minus number?

Your information is great appreciated,





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default DateSerial function

On Dec 11, 12:29*pm, "Rick Rothstein"
wrote:
And to answer your question directly, yes, DateSerial will properly handle
the year when the month goes negative.

--
Rick (MVP - Excel)

"Rick Rothstein" wrote in message

...



Are you attempting to construct a loop that will iterate through each day
of the previous 12 months? If so, you can do that directly in the For
statement of your For..Next loop. Consider this (and notice that D is
declared as Date)...


Sub Test()
*Dim D As Date
*For D = DateAdd("m", -12, Date) To Date
* *Debug.Print D
*Next
End Sub


The above code will print the date for each day for the previous year....
just replace it with the code you actually want to operate on those days.


--
Rick (MVP - Excel)


"inungh" wrote in message
....
I would like to calculate rollong calendar from today in the loop.


For example, today is Dec/11/2008 and I need to get all informaiton 12
months before today. (from Dec/11/2007 to Dec/11/2008).


I just wonder can DateSerila do the job.


For example, DateSerial(MyYear, MyMonth - i, MyDay)


Will DateSerial changed the year if the month is minus number?


Your information is great appreciated,- Hide quoted text -


- Show quoted text -


Thanks millions,


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recreating the DateSerial()/Date() function Conan Kelly Excel Worksheet Functions 1 March 1st 08 04:43 AM
Recreating the DateSerial()/Date() function Conan Kelly Excel Programming 1 March 1st 08 04:43 AM
using dateserial in vb mwam423 Excel Programming 3 June 14th 07 02:45 AM
DateSerial Troubles rockerx Excel Programming 1 March 14th 07 08:14 PM
Time/DateSerial Numeric Value Jay Excel Worksheet Functions 4 March 16th 05 03:34 AM


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"