Results 1 to 5 of 5

Thread: Display Previous Month

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    18

    Thumbs down Display Previous Month

    Hello I am working on a Report in SQL Server 2003

    I have a text box showing the date:

    textbox.Value =TODAY()

    Please could some body tell me how I could display the date for just the previous month.

    I want only the Month to be displayed.

    Thank you,

  2. #2
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,916

    Re: Display Previous Month

    You don't say how you're interfacing with SQL Server, but the following code (VB6) will display last month as a string, eg 'March'
    VB Code:
    1. Dim LastMonth As Integer
    2.     LastMonth = Month(Date) - 1
    3.    
    4.     If LastMonth = 0 Then
    5.         LastMonth = 12
    6.     End If
    7.    
    8.     MsgBox "Last month was " & MonthName(LastMonth)
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  3. #3
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Display Previous Month

    you can also do it like this
    VB Code:
    1. Dim LastMonth
    2. LastMonth = Format(DateAdd("m", -1, Format(Now, "mm/dd/yy")), "mmmm")
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    18

    Re: Display Previous Month

    This is a reporting Services Report project which I created in VS 2003

    When I drag and drop a text box onto a report design.
    Then Under properties
    I want to be able to show the previous month name.

    Please could somebody help

  5. #5
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Display Previous Month

    aren't you using vb?
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width