Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to constract a date

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi

I have a query where on the line criteria I have a string [Please enter a month] to prompt a user for the month.

What I want to do is to have my criteria look like that
Criteria: > [Enter Month]/10/02

So, I would filter my date field to be later than a 10th of the month entered by the user.

Sorry, I know this forum isn't exactly on how to build a query, but you guys been so helpful to me, so I decided to post this here

Hope to hear some tips from you

Thanks a lot
 
You can do this several ways.

You can have a month field (numeric format)
Please Enter a month, and the user enters a number from 1-12.

Then you can construct a field on-the-fly which is a concatenation of the month field and the following string "/10/02".

Put this in a blank field in a query
[month] & "/10/02"

Try that and let me know if all goes well.

David I'm Your Huckleberry!
 
YOU NEED TO USE

DateSerial(2002,[ENTERMONTH],10)
 
Thanks a lot guys, both ways solved the problem

Well, would you also have an idea how would I check how many days in the month entered?
 
Re days in month:
Code:
Function LastDay(pMoYr As String) As Date
  '*******************************************
'Name:      LastDay (Function)
'Purpose:   Returns last day of inputted month
'Inputs:    from debug window:
'               (1) ? lastday(&quot;02/2002&quot;)<enter>
'               (2) ? LastDay(&quot;02/2000&quot;)<enter>
'Output:    (1) 2/28/02
'               (2) 2/29/00
'Note:       With dates > 12/2000, pMoYr
'               must be entered in the mm/yyyy
'               format to avoid confusing the
'               system.  Dates < 01/2001 may
'               be entered as mm/yy
'*******************************************
Dim dteMyDate As Variant

   dteMyDate = DateValue(pMoYr)
   LastDay = DateSerial(Year(dteMyDate), Month(dteMyDate) + 1, 0)

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top