Calculating dates of previous month...


Author
Message
StarkMike
StarkMike
StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Here's how I am determining the first and last day of the previous month.



Me.tbdtpStartDate.EditValue = DateSerial(Year(Now()), Month(Now()) - 1, 1)

Me.tbdtpEndDate.EditValue = DateSerial(Year(Now()), Month(Now()), 0)



It seems to me there should be a more elegant way in VB .NET. Does anybody know of one?

StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You can do it the more .NET way like this:

Dim n As DateTime = DateTime.Now
Me.tbdtpStartDate.EditValue = New DateTime(n.Year, n.Month - 1, 1)
Me.tbdtpEndDate.EditValue = New DateTime(n.Year, n.Month - 1, DateTime.DaysInMonth(n.Year, n.Month - 1))

StarkMike
StarkMike
StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)StrataFrame User (450 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Thanks Ben. Too bad I couldnt go Now.PreviousMonth

Wink

StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yeah, but you could write a helper method that would encapsulate it Wink
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search