[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Finding a Date based on parameter

Posted on 2006-11-06
3
Medium Priority
?
265 Views
Last Modified: 2010-05-18
Good Afternoon

My current project involves finding dates relative to a "certain" date itself.  Can you all suggest if there is a method to help me produce the desired
result.  Here is what I am looking for:

FirstOfMonth - Date of the first day of current month
LastOfMonth - Date of the last day of current month
FirstOfLastMonth - Date of the first day of previous month
LastOfLastMonth - Date of the last day of previous month
FirstOfYear - Date of first day of the year
LastOfYear - Date of last day of the year
CurrentWeekMonday - Date of Monday of the current week(If it is Sunday then tommorrow, else today or last Monday.)
CurrentWeekFriday - Date of Friday of the current week(Future Friday unless today is Fri or Sat)
LastWeekMonday - Date of Monday of previous week(If it is Sunday then 6 days ago, else the last week's Monday at least 7 days ago)
LatWeekFriday - Date of Friday of previous week(Previous Friday 2 to 8 days ago)

Thanks for the help,
Ed
0
Comment
Question by:lbsi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 17883841
   Function FirstOfMonth() As DateTime
        Return New DateTime(Now().Year, Now.Month, 1)
    End Function

    Function LastOfMonth() As DateTime
        Return New DateTime(Now().AddMonths(1).Year, Now().AddMonths(1).Month, 1).AddDays(-1)
    End Function

    Function FirstOfLastMonth() As DateTime
        Return New DateTime(Now().AddMonths(-1).Year, Now().AddMonths(-1).Month, 1)
    End Function

    Function LastOfLastMonth() As DateTime
        Return FirstOfLastMonth().AddDays(-1)
    End Function

I hope you can continue this.
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 17883879
   Function FirstOfYear() As DateTime
        Return New DateTime(Now.Year, 1, 1)
    End Function

    Function LastOfYear() As DateTime
        Return New DateTime(Now.AddYears(1).Year, 1, 1).AddDays(-1)
    End Function
0
 

Author Comment

by:lbsi
ID: 17884185
Thanks for the help...I knew there had to be an easier way than what I was trying.

Have a good day,
Ed
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question