Results 1 to 2 of 2

Thread: Date functions

  1. #1
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    200

    Unanswered: Date functions

    HI guys ,

    I have an int called mon

    This is got as :
    *******************************
    curmonth = Format$(Now(), "mmm")
    curyr = Format$(Now(), "yyyy")
    if currmonth="Jan" then
    mon = CInt(Format$(Me.Date.Value, "mm"))-1
    year = Cstr(Cint(Format$(Me.Date.Value, "yyyy"))-1)
    else
    mon = CInt(Format$(Me.Date.Value, "mm"))
    year = Format$(Me.Date.Value, "yyyy")
    end if


    Month = Format$(mon, "mmmm")

    *********************
    I want to get the value of date entered in the date field,and if month is Jan,i need to make month show Dec and previous year.

    But i always get this as "January"

    CAn't i pass a variable to the format function to convert it back to a Date.I get the currect value in the mon variable,but it does not reflect in Format function.
    Please help on this.

    Thanks
    Michael

  2. #2
    Join Date
    Jan 2004
    Location
    Australia
    Posts
    15

    Re: Date functions

    I think I understand what you are trying to do. Try the following.


    Function Date_Functions()

    Dim CurDay As Integer, CurMon As Integer, CurYear As Integer
    Dim DateVal As Date
    Dim MonthAsString As String

    CurDay = Day(Date) 'Not actually used. Viewing purposes only.
    CurMon = Month(Date)
    CurYear = Year(Date) 'Not used

    If CurMon = 1 Then
    DateVal = DateAdd("m", -1, Date)
    Else
    DateVal = Date
    End If

    MonthAsString = Format(DateVal, "mmmm")

    End Function

Posting Permissions

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