PDA

Click to See Complete Forum and Search --> : extract just the month and year from a record with date 4/5/00


Bebe
Apr 5th, 2000, 09:48 PM
Can anyone help me with the code using VB6 and using SQL code to:

the user selects from a drop down box the month from one drop down box and the year from another drop down box

cboMonth
cboYear

cboMonth leaves you with text, example "January". I think I would then need to turn this into "1" somehow. the Year is formatted as 2000 but I need it to query the database as "00"

How do I take what the user selects in a form and query the database date for just the month and year; doing nothing with the day.

The report for example is run once a month. If they select March. They need to get a count of how many records were inputted for the month of March. I use the field Date_Opened to query this as it is a required field. So when they select March for the month and 2000 for the year or 00 I need it to go to the database select Date_Opened and look for all records beginning in that field with "3" and then query the year portion and find only records that are from the cboYear field. So although I have a day, I need to do nothing with that field.

Anybody have any good ideas on how I could do this with code or the SQL code to do this,

thanks in advance :)

bsmith
Apr 5th, 2000, 10:28 PM
Here is a select statement that will work.

select * from table_name where DatePart(year,date_field)=1999 and DatePart(month,date_field)=01

You will need to put your table name and variable names in. I am using SQL server. If you are using access there are similar functions that you can use to get a part of the date.