Results 1 to 8 of 8

Thread: Date in words [Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    104

    Resolved Date in words [Resolved]

    Hi guys, I need to display the date in words but I have no idea on where to start. What i mean by "in words" is for example the date that I got is 5/24/2005, I should display this as May 25, 2005. Could you guys please help me on this one? Also, Im trying to retrieve the first day of the week. For instance, if today is wednesday, May 18 then when i click a button it should appear May 16 (since monday is the start of the week). Please help. Thanks in advance guys.
    Last edited by trex; May 19th, 2005 at 02:20 AM.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Date in words

    FormatDateTime([date], vbLongDate)

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Date in words

    Quote Originally Posted by trex
    Hi guys, I need to display the date in words but I have no idea on where to start. What i mean by "in words" is for example the date that I got is 5/24/2005, I should display this as May 25, 2005. Could you guys please help me on this one? Also, Im trying to retrieve the first day of the week. For instance, if today is wednesday, May 18 then when i click a button it should appear May 16 (since monday is the start of the week). Please help. Thanks in advance guys.
    For the first case :
    VB Code:
    1. MsgBox Format(#5/30/2005#, "dddd mmmm dd, yyyy")

    For the second case:
    VB Code:
    1. MsgBox Format(#5/30/2005# - Weekday(#5/30/2005#, vbMonday) + 1, "dddd mmmm dd, yyyy")

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Date in words

    To get the date of the first day of the current week:
    VB Code:
    1. MsgBox FormatDateTime(DateAdd("d", -Weekday(Now, vbMonday) + 1, Now), vbLongDate)
    This use the Weekday function that returns a value between 1 and 7 depending on which weekday it is. 1 = the first day of the week. The second argument to the Weekday function specifies which day that should be considered to be the first day of the week, many countries consider Sunday as the first day (and is also the default value for this argument). You can also use vbUseSystem for this argument that will use the weekday specified by your regional settings.

    Edit: Sorry Pradeep1210, I didn't see your post. However it might be easier to use the datediff function then substracting two dates, since you don't know what date the current date is.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    104

    Re: Date in words

    Thank you so much for all your help,guys. i really appreciate it.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    104

    Re: Date in words

    hmmm i'm getting the correct date now but it also displays the day ie Tuesday, Wednesday etc. is there a way for me to remove this?

  7. #7
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872

    Re: Date in words

    just change
    VB Code:
    1. MsgBox Format(#5/30/2005#, "dddd mmmm dd, yyyy")
    to

    VB Code:
    1. MsgBox Format(#5/30/2005#, "mmmm dd, yyyy")

    "dddd" means that he has to display the name of the day

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    104

    Re: Date in words

    hahahaha how silly of me... thank you so much robbedaya

Posting Permissions

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



Click Here to Expand Forum to Full Width