To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Reporting (Crystal, Access and Data Designer)

Reply Post New Thread
 
Thread Tools Display Modes
Old Mar 26th, 2005, 06:05 AM   #1
vbcoder2
Lively Member
 
Join Date: Nov 02
Posts: 83
vbcoder2 is an unknown quantity at this point (<10)
First and Last Day Of Month

Hi Friends I need to Know the First and Last Day of Month . The PArameter is of Month Code.... i m using Seagate Crystal Report 8. ....
vbcoder2 is offline   Reply With Quote
Old Nov 7th, 2006, 12:36 PM   #2
Chrissy
Addicted Member
 
Join Date: Aug 04
Location: Itasca, IL USA
Posts: 165
Chrissy is on a distinguished road (10+)
Re: First and Last Day Of Month

Hi there.. I was justing searching the forums to find a way to get the last day in any given month in Crystal Reports.

Did you ever figure that out?
Chrissy is offline   Reply With Quote
Old Nov 8th, 2006, 04:34 AM   #3
Mark Gambo
Giants World Champs!!!!
 
Mark Gambo's Avatar
 
Join Date: Sep 03
Location: Colorado
Posts: 2,965
Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)
Re: First and Last Day Of Month

Well the first day of the Month should be the first, right ?
and you could use the following to find the last day of the month:


VB Code:
  1. Dim dtDate as Date
  2. dtDate = "09/09/2005"
  3. DateAdd("m",DateSerial(Year(dtDate), Month(dtDate), 1) - 1
__________________
Regards,

Mark

Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."

Mark Gambo is offline   Reply With Quote
Old Nov 8th, 2006, 04:37 AM   #4
Mark Gambo
Giants World Champs!!!!
 
Mark Gambo's Avatar
 
Join Date: Sep 03
Location: Colorado
Posts: 2,965
Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)
Re: First and Last Day Of Month

Here is another LINK that finds the number of days in a month
__________________
Regards,

Mark

Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."

Mark Gambo is offline   Reply With Quote
Old Nov 8th, 2006, 06:35 AM   #5
shakti5385
Just Married
 
shakti5385's Avatar
 
Join Date: Mar 06
Location: Udaipur,Rajasthan(INDIA)
Posts: 3,742
shakti5385 has a spectacular aura about (150+)shakti5385 has a spectacular aura about (150+)
Re: First and Last Day Of Month

Quote:
Originally Posted by Mark Gambo
Here is another LINK that finds the number of days in a month
I thought they want the formula in the CR not in the VB.
__________________
My Blog : My Article of the day
shakti5385 is offline   Reply With Quote
Old Nov 8th, 2006, 09:20 AM   #6
Mark Gambo
Giants World Champs!!!!
 
Mark Gambo's Avatar
 
Join Date: Sep 03
Location: Colorado
Posts: 2,965
Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)
Re: First and Last Day Of Month

Quote:
Originally Posted by shakti5385
I thought they want the formula in the CR not in the VB.
Hmmm, maybe so but with the examples I supplied the op should be able to create the CR Formula.
__________________
Regards,

Mark

Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."

Mark Gambo is offline   Reply With Quote
Old Nov 8th, 2006, 09:29 AM   #7
Mark Gambo
Giants World Champs!!!!
 
Mark Gambo's Avatar
 
Join Date: Sep 03
Location: Colorado
Posts: 2,965
Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)
Re: First and Last Day Of Month

But here is the CR Formula:


VB Code:
  1. DateAdd("m",1,DateSerial(Year({Table1.dtDate}), Month({Table1.dtDate}),1))-1

@ Shakti - Looks like my code in post #3 except without the Variable.
__________________
Regards,

Mark

Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."

Mark Gambo is offline   Reply With Quote
Old Nov 8th, 2006, 09:46 AM   #8
Mark Gambo
Giants World Champs!!!!
 
Mark Gambo's Avatar
 
Join Date: Sep 03
Location: Colorado
Posts: 2,965
Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)
Re: First and Last Day Of Month

__________________
Regards,

Mark

Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."

Mark Gambo is offline   Reply With Quote
Old Nov 9th, 2006, 04:42 AM   #9
ganeshmoorthy
VB Guru
 
ganeshmoorthy's Avatar
 
Join Date: Dec 05
Location: Sharjah, United Arab Emirates
Posts: 3,031
ganeshmoorthy is a jewel in the rough (200+)ganeshmoorthy is a jewel in the rough (200+)ganeshmoorthy is a jewel in the rough (200+)
Re: First and Last Day Of Month

@Mark Gambo, if you find the last day of the month that itself will tell you the no of days in that month...lol...
__________________
If an answer to your question has been helpful, then please, Rate it!

Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
http://ganeshmoorthymc.com
ganeshmoorthy is offline   Reply With Quote
Old Nov 9th, 2006, 05:35 AM   #10
Mark Gambo
Giants World Champs!!!!
 
Mark Gambo's Avatar
 
Join Date: Sep 03
Location: Colorado
Posts: 2,965
Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)
Re: First and Last Day Of Month

Quote:
Originally Posted by ganeshmoorthy
@Mark Gambo, if you find the last day of the month that itself will tell you the no of days in that month...lol...
Huh??
__________________
Regards,

Mark

Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."

Mark Gambo is offline   Reply With Quote
Old Nov 9th, 2006, 05:42 AM   #11
shakti5385
Just Married
 
shakti5385's Avatar
 
Join Date: Mar 06
Location: Udaipur,Rajasthan(INDIA)
Posts: 3,742
shakti5385 has a spectacular aura about (150+)shakti5385 has a spectacular aura about (150+)
Arrow Re: First and Last Day Of Month

Quote:
Originally Posted by Mark Gambo
Huh??
He was saying that in the VB, DTPicker.Day Return the last day of the month.
__________________
My Blog : My Article of the day
shakti5385 is offline   Reply With Quote
Old Nov 9th, 2006, 06:36 AM   #12
Mark Gambo
Giants World Champs!!!!
 
Mark Gambo's Avatar
 
Join Date: Sep 03
Location: Colorado
Posts: 2,965
Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)Mark Gambo is a jewel in the rough (200+)
Re: First and Last Day Of Month

Quote:
Originally Posted by shakti5385
He was saying that in the VB, DTPicker.Day Return the last day of the month.
If you are referring to Post # 4, I just included it because it was germane to the discussion and some of us don't use the DatePicker Control in their apps. BTW, where in this thread was the DatePicker control discussed?
__________________
Regards,

Mark

Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."

Mark Gambo is offline   Reply With Quote
Old Nov 9th, 2006, 06:47 AM   #13
shakti5385
Just Married
 
shakti5385's Avatar
 
Join Date: Mar 06
Location: Udaipur,Rajasthan(INDIA)
Posts: 3,742
shakti5385 has a spectacular aura about (150+)shakti5385 has a spectacular aura about (150+)
Wink Re: First and Last Day Of Month

I am making the formula in the CR related to it. And I am not discussing here on the VB property like dtpicker, the people here related on the reporting post, let wait for the thread starter reply.
Dtpicker is not a metter here.
__________________
My Blog : My Article of the day
shakti5385 is offline   Reply With Quote
Old Apr 5th, 2007, 02:28 AM   #14
shakti5385
Just Married
 
shakti5385's Avatar
 
Join Date: Mar 06
Location: Udaipur,Rajasthan(INDIA)
Posts: 3,742
shakti5385 has a spectacular aura about (150+)shakti5385 has a spectacular aura about (150+)
Arrow Re: First and Last Day Of Month

Quote:
Originally Posted by Mark Gambo
But here is the CR Formula:


VB Code:
  1. DateAdd("m",1,DateSerial(Year({Table1.dtDate}), Month({Table1.dtDate}),1))-1

@ Shakti - Looks like my code in post #3 except without the Variable.
This is also not giving the result, In CR it dispalying the Date only not the last day of Month.
__________________
My Blog : My Article of the day
shakti5385 is offline   Reply With Quote
Old Jul 3rd, 2009, 10:02 PM   #15
winwin
New Member
 
Join Date: Jul 09
Posts: 2
winwin is an unknown quantity at this point (<10)
Re: First and Last Day Of Month

'try this......... 2 DTpicker set to First and Last day of the month



Private Sub Form_Load()
DTPicker1.Value = DateAdd("d", -(Day(Date) - 1), Date)
DTPicker2.Value = DateAdd("d", (getNumberOfDays - 1), DTPicker1.Value)
End Sub
'Get the number of days each month is having
Public Function getNumberOfDays() As Integer
Select Case DateTime.Month(Date)
Case 1, 3, 5, 7, 8, 10, 12
getNumberOfDays = 31
Case 4, 6, 9, 11
getNumberOfDays = 30
Case 2
'logic for checking leap years
If (Year(Date) Mod 4) = 0 Then
If (Year(Date) Mod 100) = 0 Then
If (Year(Date) Mod 400) = 0 Then
getNumberOfDays = 29
Else
getNumberOfDays = 28
End If
Else
getNumberOfDays = 29
End If
Else
getNumberOfDays = 28
End If
End Select
End Function
winwin is offline   Reply With Quote
Old Jul 3rd, 2009, 10:05 PM   #16
winwin
New Member
 
Join Date: Jul 09
Posts: 2
winwin is an unknown quantity at this point (<10)
Re: First and Last Day Of Month

'try this......... 2 DTpicker set to First and Last day of the month



Private Sub Form_Load()
DTPicker1.Value = DateAdd("d", -(Day(Date) - 1), Date)
DTPicker2.Value = DateAdd("d", (getNumberOfDays - 1), DTPicker1.Value)
End Sub

'Get the number of days each month is having
Public Function getNumberOfDays() As Integer
Select Case DateTime.Month(Date)
Case 1, 3, 5, 7, 8, 10, 12
getNumberOfDays = 31
Case 4, 6, 9, 11
getNumberOfDays = 30
Case 2
'logic for checking leap years
If (Year(Date) Mod 4) = 0 Then
If (Year(Date) Mod 100) = 0 Then
If (Year(Date) Mod 400) = 0 Then
getNumberOfDays = 29
Else
getNumberOfDays = 28
End If
Else
getNumberOfDays = 29
End If
Else
getNumberOfDays = 28
End If
End Select
End Function
winwin is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Reporting (Crystal, Access and Data Designer)


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:02 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.