Consulting

Results 1 to 4 of 4

Thread: Solved: Date Formating?

  1. #1

    Talking Solved: Date Formating?

    Hello,
    is't any vba code to return any date to day first.

    example :
    01/03/2006 to 01/03/2006
    05/03/2006 to 01/03/2006
    11/04/2006 to 01/04/2006


    Thanks,

    Mohd Azrie
    Bt Pahat, Johor, Malaysia.

  2. #2
    This may help. Actually, it's designed to work as a worksheet function, but if you change the input parameter to date or string type, you can use it in regular code. You might have to alter it a little, (i.e. change the order of day, month, year) depending on how your system handles date.

    [vba] Function ReduceDate(cell As Range) As Date
    Dim a As String
    a = "1/" & CStr(Month(cell.Value)) & "/" & CStr(Year(cell.Value))
    ReduceDate = CDate(a)
    End Function[/vba]
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  3. #3
    Hmm... I just receive interesting solution could be share to others,

    CurDate = Date
    NewDate = DateAdd("d",-(Day(CurDate)-1),CurDate)

    I'ts works .

    Mohd Azrie
    Bt Pahat, Johor, Malaysia.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You don't need DateAdd

    [vba]
    CurDate = Date
    NewDate = CurDate - Day(CurDate) + 1
    [/vba]

Posting Permissions

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