|
-
Jan 22nd, 2003, 06:41 PM
#1
Thread Starter
Lively Member
Simple date question
I should know this, but how do you find the first day of the next month. Today is 1/22/2003. I need 2/01/2003.
Thanks much,
-
Jan 23rd, 2003, 08:24 AM
#2
Fanatic Member
Ray, try this.
VB Code:
Dim curdate As New Date()
Dim nextmonth As Date
curdate = System.DateTime.Today
nextmonth = curdate.AddMonths(1)
nextmonth = New Date(nextmonth.Year, nextmonth.Month, 1)
MessageBox.Show("First day of next month: " & nextmonth.ToString())
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Jan 23rd, 2003, 08:37 AM
#3
Thread Starter
Lively Member
-
Jan 23rd, 2003, 02:22 PM
#4
Sleep mode
Mr.No Good Job !
I was doing something quite similar but this error was preventing me running the code .
VB Code:
'this code is fine
Dim Td As Date
Dim NxM As Date
MsgBox("Today is " & DateTime.Today)
'but when I assign the vari Td like so , I get error says :
' Value of type 'Date' cannot be converted to '1-dimensional array
'of Date'.
Dim Td As Date()
Dim NxM As Date
MsgBox("Today is " & DateTime.Today)
'the error shows in the next two lines
Td = DateTime.Today ' 1
NxM = Td.AddMonths(1) '2
MsgBox(NxM.ToString)
Cany anyone explain this . thanx .
-
Jan 24th, 2003, 09:25 AM
#5
Fanatic Member
pirate
I tried the following to avoid the errors. It seems that you have to create an instance of td using New to allow it receive the Today property from the DateTime structure. Strangely enough the DateTime text doesn't become blue in the IDE.
I added the variables appended with 2 to try variables of type DateTime.
VB Code:
Dim Td As New Date() ' New is required
Dim NxM As Date
Dim NxM2 As Date
Dim td2 As New DateTime() ' New is required
MsgBox("Today is " & DateTime.Today)
'the error shows in the next two lines
'system.DateTime. The error is not occur anymore when
' you use the New keyword while declaring Td.
Td = DateTime.Today() ' 1
td2 = DateTime.Today()
NxM = Td.AddMonths(1) '2
NxM2 = td2.AddMonths(1)
MessageBox.Show(NxM.ToString)
MessageBox.Show(NxM2.ToString)
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Jan 24th, 2003, 12:27 PM
#6
Sleep mode
mr.no , here is your code back with little change . It works fine as I'm saying, no need to instantiate a new object of Date and DateTime Classes.They seem to be Static Classes(Shared).The problem back when I add two parenthesis at the end.It has something to do with damn arrays.
VB Code:
Dim Td As Date ' New is required
Dim NxM As Date
Dim NxM2 As Date
Dim td2 As DateTime ' New is required
MsgBox("Today is " & DateTime.Today)
'the error shows in the next two lines
'system.DateTime. The error is not occur anymore when
' you use the New keyword while declaring Td.
Td = DateTime.Today() ' 1
td2 = DateTime.Today()
NxM = Td.AddMonths(1) '2
NxM2 = td2.AddMonths(1)
MessageBox.Show(NxM.ToString)
MessageBox.Show(NxM2.ToString)
-
Jan 27th, 2003, 02:58 AM
#7
Fanatic Member
Sorry pirate
I can't think of anything yet.
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|