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

Date Problem

Status
Not open for further replies.

bw2601

Technical User
Dec 16, 2004
29
US
I have a form in which i need to enter information the day after it happens for the day before. so Tuesday i would enter on Monday's date.

I did this by entering Date()-1 in the Default value under properties.

now the problem i am having is Monday. I need Monday to go the the previous Friday.

Does any one have any ideas on how i can do this one?

any help would be appreciated.
thank you
 
Check out the weekday function. Something like, "if weekday(date()) = 2, then show me date() - 3" or some variation on that them.
 
How are ya bw2601 . . . . .
Code:
[blue]= IIf(Weekday(Now()) = 2, Now() - 3, IIf(Weekday(Now()) > 2 And Weekday(Now()) < 7, Now[/blue]
() - 1, Null))

Calvin.gif
See Ya! . . . . . .
 
Now, this is a forms question, and should rather be posted in the Forms forum (forum702), but a snippet for this, which can be used in a relevant form event (on current?), could perhaps be something like this

[tt]dim dtMyDate as date
dtMyDate = date
select case weekday(dtMyDate,vbsunday)
case 1 ' OT - sunday?
me!txtMyDate.value = dtMyDate - 2
case 2
me!txtMyDate.value = dtMyDate - 3
case else
me!txtMyDate.value = dtMyDate - 1
end select[/tt]

- note that you'd probably want to check whether there are some contents in the control you're assigning too, or if it's a new records... to prevent overwriting existing values...

Roy-Vidar
 
Sorry about the mess!
Code:
[blue]= IIf(Weekday(Now()) = 2, Now() - 3, IIf(Weekday(Now()) > 2 And Weekday(Now()) < 7, Now() - 1, Null))[/blue]

Calvin.gif
See Ya! . . . . . .
 
you guys are the best, i ended up using a combo of both. and it does exactly what i wanted it to do. thank you for the pointers, you saved me a lot of time and frustration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top