DatePart

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a date field with data in date format i.e. 6/17/2004. In a report column, I want to display 6/17. I am trying to use datepart to do this but I can't get the syntax right. Can anyone help? Thanks.
 
DatePart can only give you one part of the date: only the day, only the
month, and so on. To get both, either use the Format function:

Format([MyDate], "m/d")

or use DatePart twice:

DatePart("m", [MyDate]) & "/" & DatePart("d", [MyDate])

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



FRANK said:
I have a date field with data in date format i.e. 6/17/2004. In a report
column, I want to display 6/17. I am trying to use datepart to do this but I
can't get the syntax right. Can anyone help? Thanks.
 
FRANK said:
I have a date field with data in date format i.e. 6/17/2004. In a
report column, I want to display 6/17. I am trying to use datepart to
do this but I can't get the syntax right. Can anyone help? Thanks.

It's probably easiest just to use the Format property of the text box,
or the Format function, to format the date field the way you want. The
format string you want is "m/dd". For example

?Format(#6/17/2004#, "m/dd")
6/17
 
You could use the Format() function:

Format([MyDateField], "m/d")
or
Format([MyDateField], "mm/dd")



--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


FRANK said:
I have a date field with data in date format i.e. 6/17/2004. In a report
column, I want to display 6/17. I am trying to use datepart to do this but I
can't get the syntax right. Can anyone help? Thanks.
 
Back
Top