|
-
Apr 18th, 2006, 06:36 PM
#1
Thread Starter
Junior Member
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,
-
Apr 19th, 2006, 03:25 AM
#2
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:
Dim LastMonth As Integer
LastMonth = Month(Date) - 1
If LastMonth = 0 Then
LastMonth = 12
End If
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.
-
Apr 19th, 2006, 03:54 AM
#3
Frenzied Member
Re: Display Previous Month
you can also do it like this
VB Code:
Dim LastMonth
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
-
Apr 19th, 2006, 10:16 AM
#4
Thread Starter
Junior Member
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
-
Apr 19th, 2006, 08:37 PM
#5
Frenzied Member
Re: Display Previous Month
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|