Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Unanswered: DatePart function problems

    Hi,
    I seem to have a problem with DatePart. I have a field(s) (on a form) that I want to only show part of the date/time using the DatePart function on Now().
    But I have a problem where it only works for some. E.G. I have the default value set as
    DatePart("Y",Now())
    unfortunately this is showing the last 2 digits if the year not the number of the day in the year. Also the following seem to work or nto work.

    yy = error
    yyyy = OK
    d = OK
    dd = error
    ddd= error
    dddd = error
    ddddd = error
    ddddd = error
    w = OK
    ww =OK
    m = OK
    mm = error
    mmm = error
    mmmm = error
    q = OK
    tttt = error

    Have I got this "around my neck" and not using DatePart as it is meant to be used?

    Regards
    John

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    datepart("yyyy",date())

    datepart("yyyy",now)

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    datepart("yyyy",date())
    shows 2004

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: DatePart function problems

    Originally posted by Sticker
    Hi,
    I seem to have a problem with DatePart. I have a field(s) (on a form) that I want to only show part of the date/time using the DatePart function on Now().
    But I have a problem where it only works for some. E.G. I have the default value set as
    DatePart("Y",Now())
    unfortunately this is showing the last 2 digits if the year not the number of the day in the year. Also the following seem to work or nto work.

    yy = error
    yyyy = OK
    d = OK
    dd = error
    ddd= error
    dddd = error
    ddddd = error
    ddddd = error
    w = OK
    ww =OK
    m = OK
    mm = error
    mmm = error
    mmmm = error
    q = OK
    tttt = error

    Have I got this "around my neck" and not using DatePart as it is meant to be used?

    Regards
    John
    John,

    What are you trying to display exactly? If it's the month or day and year try using the format function. Ex:

    Format(Now,"mm yyyy")

    or

    Format(Now,"dd yyyy")

  5. #5
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi guys
    Thanks for your replys, I have tried the Fromat command and that is giving me what I need.

    Thanks again for your help

    Regards
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •