Results 1 to 3 of 3

Thread: [RESOLVED] Oracle 9i: DateTimePicker.Value to Date DataType

  1. #1

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Resolved [RESOLVED] Oracle 9i: DateTimePicker.Value to Date DataType

    Hi all,
    I'm no DB expert and this is my first time working with Oracle so bear with me. I have two DateTimePickers (sellOffStart and sellOffEnd) which I use their values when querying the database. So, I'm doing this:
    vb.net Code:
    1. Dim sql As String = _
    2.     "select  " & _
    3.         "cus.FIELD_VALUE as ""Sell Off Date"", " & _
    4.         "ag.AGREEMENTS_ABBR as ""Licensor Number"", " & _
    5.         "ag.AGREEMENTS_NAME as ""Project"" " & _
    6.     "from V_REPCUSTOMFIELDDATA cus " & _
    7.         "right join V_AGREEMENT ag " & _
    8.             "on cus.ASSOCIATED_WITH_INTERNAL_KEY = ag.CONTRACT_CODE " & _
    9.     "where " & _
    10.         "cus.INTERNAL_DESCRIPTIONS_CODE = 35 " & _
    11.         "and ag.AGREEMENTS_ABBR LIKE :licensorNum " & _
    12.         "and cus.FIELD_VALUE between " & _
    13.             "to_date(:sellOffStart, 'MM/DD/YY HH12:MI:SS AM') and to_date(:sellOffEnd, 'MM/DD/YY HH12:MI:SS AM') " & _
    14.     "order by " & _
    15.         """Sell Off Date"", " & _
    16.         """Licensor Number"""
    17.  
    18. Dim cmd As New OracleCommand(sql, conn)
    19. cmd.Parameters.AddWithValue("licensorNum", "%" & Me.sellOffLicensorNum.Text & "%")
    20. cmd.Parameters.AddWithValue("sellOffStart", Me.sellOffStart.Value.ToString())
    21. cmd.Parameters.AddWithValue("sellOffEnd", Me.sellOffEnd.Value.ToString())

    Am I supposed to ToString() the DateTimePicker.value and then use Oracle's TO_DATE() to turn that string right back into Oracle's DATE? Is this how I am supposed to do this?

    It works, but I'm just curious if this is the "correct" way.

    Thanks for helping this DB rookie.

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Oracle 9i: DateTimePicker.Value to Date DataType

    Yes. The Oracle date type needs to have the date (by default it expects DD-MON-YY) spelled out if not in the default. And To_Date function expects a string type
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: Oracle 9i: DateTimePicker.Value to Date DataType

    I guess I could also convert to Oracle's expected date format in the DateTimePicker's value.ToString() method but I imagine it doesn't matter either way.

    Thanks!

    (and with Gary weighing in on an Oracle topic....thread resolved! )

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