Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Posts
    395

    Unanswered: Date type variable displays the time instead of date

    Why is the variable with Date type displaying the time instead of date?Public Function ConvToDate(ByVal Quarter As Quarters, ByVal intYear As Integer)


    Dim ConvDate As Date


    Select Case Quarter
    Case Quarter_1
    ConvDate = CDate("01/01/" & Str(intYear))
    Case Quarter_2
    ConvDate = CDate("04/01/" & Str(intYear))
    Case Quarter_3
    ConvDate = CDate("07/01/" & Str(intYear))
    Case Quarter_4
    ConvDate = CDate("10/01/" & Str(intYear))
    End Select

    Debug.Print ConvDate ''Displays correct date format

    End Function


    Private Sub PassingStartDate()
    Dim sqtr As String
    Dim syr As String
    Dim startdate As Date
    Dim ConvDate As Date

    sqtr = Left$(cboSQtr, 1)
    syr = cboSYear


    startdate = ConvToDate(sqtr, syr)

    Debug.Print startdate '''Displays 12:00:00 AM instead of the date


    End Sub


    Thanks!!

  2. #2
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    I've had trouble with this myself. The date field in question is Null. For some reason, 12:00:00 AM, is returned instead of Null.

    If you check for DATE is Null, you won't get a match. But if you check for 12:00:00 AM, you get a match.

    Good Luck.
    Bruce Baasch

  3. #3
    Join Date
    May 2002
    Posts
    395

    calling function

    Originally posted by Bruce A. Baasch
    I've had trouble with this myself. The date field in question is Null. For some reason, 12:00:00 AM, is returned instead of Null.

    If you check for DATE is Null, you won't get a match. But if you check for 12:00:00 AM, you get a match.

    Good Luck.
    Hi Bruce,

    I'm hoping you can take a look of my problem and perhaps you can help me.
    In my sub procedure I'm calling a function and passing it two arguments(quarter, year). In the called function I converted the quarter into date format and concatenated the year. I placed debug in the function and the date displayed is correct and so is the format.

    Private Sub PassingStartDate()
    .
    .
    startdate = ConvToDate(sqtr, syr)

    What I am trying to do is call a function and store its returned value in a variable. Is the code correct? And is there any other I can write It?

    Thanks!! I really appreciate it.

  4. #4
    Join Date
    May 2002
    Posts
    395

    Re: calling function

    Originally posted by alicejwz
    Hi Bruce,

    I'm hoping you can take a look of my problem and perhaps you can help me.
    In my sub procedure I'm calling a function and passing it two arguments(quarter, year). In the called function I converted the quarter into date format and concatenated the year. I placed debug in the function and the date displayed is correct and so is the format.

    Private Sub PassingStartDate()
    .
    .
    startdate = ConvToDate(sqtr, syr)

    What I am trying to do is call a function and store its returned value in a variable. Is the code correct? And is there any other I can write It?

    Thanks!! I really appreciate it.

    You can disregard the last message. I found the problem it is the variable in the function. Thanks!!

Posting Permissions

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