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

Previous Month's Name Default

Status
Not open for further replies.

DLSE

Technical User
Sep 5, 2002
24
0
0
US
I'm trying to set a default in a form for the name of the previous month. For example, on June 10, 2003, the default would read "May". If its not possible to set an entire name as a default, I could also use numbers, ie. "5" for "May"
Thanks,
Matt
 
?datepart("M",dateserial(Year(date),month(#1/30/2003#)-1,day(date)))
5
 
Ignore firt post hit send in error
?datepart("M",dateserial(Year(date),month(date)-1,day(date)))
5
?format(dateserial(Year(date()),month(date())-1,day(date())),"MMM")
May
 
I had written a code about date functions which may help you out on any date function:
It is in thread702-562072
I do not know how to link it so it will take you there directly.
 
Gol4-
I used your second post, and recieved an "invalid syntax" error when I copy and pasted either into the form. Any ideas on what might be wrong?
Thanks,
Matt
 
Not if you are using access
what I posted was debug window results so should work
on a form replace ? with =

=Format(DateSerial(Year(Date()),Month(Date())-1,Day(Date())),"mmmm")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top