Results 1 to 6 of 6
  1. #1
    iProRyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Location
    England, United Kingdom
    Posts
    44

    Textbox with today's date

    Hi Guys,



    Got a problem and I can't find where I'm going wrong. I have a textbox and want it to say the current day and date like this: Thursday 19th December 2013.

    It is called txtDate and I have set the Control Source to:
    =WeekdayName(Weekday(0),False,0) & Date()

    Of which is fine, but it keeps saying Sunday instead of Thursday why is this? Can someone help?

    Thanks,
    Ryan

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Set the default value of the text box to =Date() and Format to dddd mmmm dd", "yyyy

    This will show today's date as Thursday December 19, 2013. With little tweaking, you can get the desired result except for the "th" part.
    To add the "th" may require some code. Never tried.

  3. #3
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    You were close. Try this.

    =WeekdayName(Weekday(Date(),0),False,0) & Date()

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    That'll get you

    Thursday 12/19/2013

    not

    Thursday 19th December 2013

    To get

    Thursday 19 December 2013

    you can use

    Code:
    =Format(Date(),"dddd") & " " & Day(Date()) & " " & Format(Date(),"mmmm") & " " & Format(Date(),"yyyy")


    To add the suffix to the Date, i.e. the st, nd, rd, th, etc., to get something like 19th, will require more work, and for something like this, is more work than I'd be inclined to bother with!

    Linq ;0)>

  5. #5
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Thank you for the correction. I was lost in thought at that time.

    This is what I was trying to post.

    =Format(Now(),"dddd d""" & IIf(Right(Day(Now()),2)\10=1,"th",Nz(Choose(Right( Day(Now()),1),"st","nd","rd"),"th")) & """ mmmm, yyyy")

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Your last posted code works just fine, for me, in the U.S. What Date Format is Windows set to on your machine? The Access gnomes frequently choke on anything other Format other than than MM/DD/YYYY.

    And as basic as it sounds, have you checked to make sure that the Date on your system is correct? When testing certain types of code, I'll play with changing the system dates and forget to reset it, on occasion!

    BTW, Now() returns the Time portion of the Date and Time, and many developers only use it when they absolutely need the Time, because having the Time portion can lead to problems, later. If all you need is the date, use Date().

    Linq ;0)>
    Last edited by Missinglinq; 12-19-2013 at 03:13 PM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-26-2013, 09:25 AM
  2. Replies: 3
    Last Post: 02-04-2013, 05:24 PM
  3. Replies: 7
    Last Post: 01-28-2013, 05:21 PM
  4. Replies: 5
    Last Post: 10-12-2012, 11:00 AM
  5. Replies: 12
    Last Post: 04-26-2012, 04:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums