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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entry specific calculated date 2

Status
Not open for further replies.

imtiyaz

Technical User
Aug 20, 2001
9
0
0
MY
hi,
I wnat to enter two dates per month i.e. 10th for data entry in days beyond 25th of previous month to 10th of this month & 25th for data entry in days beyond 10th to 25th of this month.
ex. say today is 21/8/01, so date field should reflect as 25/8/01.
or say today is 26/8/01, then date field should select date as 10/9/01.
or say today is 9/9/01, then date field should select date as 10/9/01.
is there a method for this?
thanks in advance.
imtiyaz
 
I would probably use an IIF function, e.g.

IIF(Day(Now)>10 and Day(Now)<26, DateSerial(Year(Now),Month(Now),25), DateSerial(Year(Now), Month(Now)+1, 10)

However, this will not work if the current month is December and some further tweaking would be required, but the above is a start. Have fun! :eek:)

Alex Middleton
 
The following code should work. It hasn't been tested however. You can call this from a query or use it as a default for a table field, or call it from a form.

Steve King


Public Function EnterDate() As Date

If Day(Date()) >= 10
EnterDate = Month(Date())/10/Year(Date())
ElseIf Day(Date()) >= 25 Then
EnterDate = Month(Date())+1/10/Year(Date())
Else
EnterDate = Month(Date())/25/Year(Date())
End If

End Function

Growth follows a healthy professional curiosity
 
[/code]
Public Function basTwoDates(DateIn As Date) As Date

Select Case Day(DateIn)
Case 10 To 25
basTwoDates = DateSerial(Year(Now), Month(Now), 10)
Case Else
basTwoDates = DateSerial(Year(Now), Month(Now) + 1, 25)
End Select

End Function
[/code] MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Disregard previous. Dog Walk obviated test.

Public Function basTwoDates(DateIn As Date) As Date

Select Case Day(DateIn)
Case Is < 10
basTwoDates = DateSerial(Year(Now), Month(Now) - 1, 25)
Case 10 To 25
basTwoDates = DateSerial(Year(Now), Month(Now), 10)
Case Is > 25
basTwoDates = DateSerial(Year(Now), Month(Now) + 1, 10)
End Select

End Function
MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
thanks everybody,

michaelred it works fine with the code u have given.
thanks again

imtiyaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top