473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

get month

46
Hi all..
I wana to get the specific date which is in database and show in the datagrid.
For example, I want key in the 'january' in a text box and want to get all january data. How I call it out? I'd tried but can't get it. My code is:
Expand|Select|Wrap|Line Numbers
  1. Adodc1.RecordSource = "select * from date where userDate LIKE 'txtMonth %'"
where userData is the field name, txtMonth is the text box i key in the month.
Please help me.
Thanks..
Jun 6 '07 #1
6 1914
samycbe
83
Dear Friend,

Have a month list in combo and on click have an invisible text box contains month value eg jan =1 mar =3 dec =12.

and write a code

select * from <Table> where datepart(m,<fieldname>) = val(txtinvmonth)

it will work

samy

Hi all..
I wana to get the specific date which is in database and show in the datagrid.
For example, I want key in the 'january' in a text box and want to get all january data. How I call it out? I'd tried but can't get it. My code is:
Expand|Select|Wrap|Line Numbers
  1. Adodc1.RecordSource = "select * from date where userDate LIKE 'txtMonth %'"
where userData is the field name, txtMonth is the text box i key in the month.
Please help me.
Thanks..
Jun 7 '07 #2
berry
46
Dear Friend,

Have a month list in combo and on click have an invisible text box contains month value eg jan =1 mar =3 dec =12.

and write a code

select * from <Table> where datepart(m,<fieldname>) = val(txtinvmonth)

it will work

samy
I write my code as:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbMonth_Click()
  2. If cmbMonth.Text = "January" Then
  3.     Text2 = 1    
  4. ElseIf cmbMonth.Text = "February" Then
  5.     Text2 = 2
  6. ElseIf cmbMonth.Text = "March" Then
  7.     Text2 = 3
  8. ElseIf cmbMonth.Text = "April" Then
  9.     Text2 = 4
  10. ElseIf cmbMonth.Text = "May" Then
  11.     Text2 = 5
  12. ElseIf cmbMonth.Text = "June" Then
  13.     Text2 = 6
  14. ElseIf cmbMonth.Text = "July" Then
  15.     Text2 = 7
  16. ElseIf cmbMonth.Text = "August" Then
  17.     Text2 = 8
  18. ElseIf cmbMonth.Text = "September" Then
  19.     Text2 = 9
  20. ElseIf cmbMonth.Text = "October" Then
  21.     Text2 = 10
  22. ElseIf cmbMonth.Text = "November" Then
  23.     Text2 = 11
  24. ElseIf cmbMonth.Text = "December" Then
  25.     Text2 = 12
  26. End If
  27. Adodc1.RecordSource = "select * from date where datepart(month,dateNow) =  Val(Text2.Text)"
  28. Adodc1.Refresh
  29. DataGrid1.Refresh
  30. End Sub
There is an error "Unkown column 'month' in 'where clause'". What's wrong there?
Jun 7 '07 #3
coolminded
137 100+
I write my code as:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbMonth_Click()
  2. If cmbMonth.Text = "January" Then
  3.     Text2 = 1    
  4. ElseIf cmbMonth.Text = "February" Then
  5.     Text2 = 2
  6. ElseIf cmbMonth.Text = "March" Then
  7.     Text2 = 3
  8. ElseIf cmbMonth.Text = "April" Then
  9.     Text2 = 4
  10. ElseIf cmbMonth.Text = "May" Then
  11.     Text2 = 5
  12. ElseIf cmbMonth.Text = "June" Then
  13.     Text2 = 6
  14. ElseIf cmbMonth.Text = "July" Then
  15.     Text2 = 7
  16. ElseIf cmbMonth.Text = "August" Then
  17.     Text2 = 8
  18. ElseIf cmbMonth.Text = "September" Then
  19.     Text2 = 9
  20. ElseIf cmbMonth.Text = "October" Then
  21.     Text2 = 10
  22. ElseIf cmbMonth.Text = "November" Then
  23.     Text2 = 11
  24. ElseIf cmbMonth.Text = "December" Then
  25.     Text2 = 12
  26. End If
  27. Adodc1.RecordSource = "select * from date where datepart(month,dateNow) =  Val(Text2.Text)"
  28. Adodc1.Refresh
  29. DataGrid1.Refresh
  30. End Sub
There is an error "Unkown column 'month' in 'where clause'". What's wrong there?

hi berry
in your query, just write "m" instead of month, it has to work.

"select * from date where datepart("m",dateNow)=Val(Text2.Text)"
Jun 8 '07 #4
debasisdas
8,127 Expert 4TB
1.add the month name to a combo.

2.instead of combo TEXT property use LISTINDEX property.

3.select * from tablename where to_char(datefield,'mm')= listindex+1


it will work for u.
Jun 8 '07 #5
nairda
39
Hi all..
I wana to get the specific date which is in database and show in the datagrid.
For example, I want key in the 'january' in a text box and want to get all january data. How I call it out? I'd tried but can't get it. My code is:
Expand|Select|Wrap|Line Numbers
  1. Adodc1.RecordSource = "select * from date where userDate LIKE 'txtMonth %'"
where userData is the field name, txtMonth is the text box i key in the month.
Please help me.
Thanks..
Hi, Berry,

1.Add the months name in to a combo (Look for "LIST" in you combo properties)

2. Try these code:
Expand|Select|Wrap|Line Numbers
  1. Adodc1.RecordSource =  "select * from date where userDate like ' %" & Combo.text & "%' "
3. You can modified when the action (Calling the data) will be ran. (After you choosed/clicked the combobox, or you can make a CommandButton to trigger the action).

I hope these would help.
NAIRDA
Jun 8 '07 #6
+
these are good but I think "Month(Date)" can be used as a macro. so this makes it easyer.
;)
Jun 8 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Finlay | last post by:
Hi Group I am designing a report that should show a meter reading for each month and the previous meter reading for the previous month. The months are text stored in a field tMonth. The...
6
by: Hasanain F. Esmail | last post by:
Hi all, I sincerly thank you all in advance for your help to solve this problem. I have been trying to find a solution to this problem for sometime now but have failed. I am working on a...
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
6
by: Nkhosinathie | last post by:
hello guys,i've started with classes and i've been given this program below to program and also i will post the source code if you need it.this program reads as folllows. create a class called...
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.