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

Another date question... 1

Status
Not open for further replies.

KevinFSI

Programmer
Nov 17, 2000
582
US
If I say
Code:
#FirstDayOfMonth(Now())#
I get 60 which is March 1 of this year. I want to be able to display the first day of each month as text, so I tried
Code:
#DateFormat(FirstDayOfMonth(Now()), "D-MMM-YY")#
but it gives me 28-Feb-00. Can I not do what I'm trying to do? Kevin
slanek@ssd.fsi.com
 
Try this:

d -- Day of the month as digits with no leading zero for single-digit days.
dd -- Day of the month as digits with a leading zero for single-digit days.
ddd -- Day of the week as a three-letter abbreviation.
dddd -- Day of the week as its full name.
m -- Month as digits with no leading zero for single-digit months.
mm -- Month as digits with a leading zero for single-digit months.
mmm -- Month as a three-letter abbreviation.
mmmm -- Month as its full name.
y -- Year as last two digits with no leading zero for years less than 10.
yy -- Year as last two digits with a leading zero for years less than 10.
yyyy -- Year represented by four digits.

I copied this from the function documentation. Hope this helps! :)
 
Sorry, Kevin. I should have read your question more carefully. I see your problem, now. I'm not sure what to do about it, but I'll take a look. You might need to consider leap years, too. :cool:
 
I got it. Probably not the best way, but it works great.
Code:
#DateFormat(DateAdd('D', FirstDayOfMonth(Now())-1, CreateDate(DatePart('YYYY', Now()), 1, 1)), "D-MMM-YY")#

Please let me know if someone has a better way. Kevin
slanek@ssd.fsi.com
 
Hey Kevin,

I may be mis-reading what you want but if you want a text string representing the first day of the current month, I think this will work for you.

#dateformat("#month(now())#/1/#year(now())#","D-MMM-YY")#

GJ
 
Yep, that does it. Hadn't thought of it. As you may have partially deduced from my earlier post, I want to be able to create a report that has each month (for 18 mos.) listed across the top with the number of working days in that month right below. Thanks a lot for the help earlier, that gave me the boost I needed. The code you posted above will shorten my own code slightly, but I got it all working now. Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top