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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Running Total 10
Data Type mismatch error 2
#Name? error - Question on Dates 6
Cross tab - complex IIF 2
Running Sum within Query 4
Retrieving one months data 1
Query Problem 4
report question 1

Back
Top