|
-
Apr 9th, 2008, 11:52 AM
#1
Thread Starter
Registered User
[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:
Dim sql As String = _
"select " & _
"cus.FIELD_VALUE as ""Sell Off Date"", " & _
"ag.AGREEMENTS_ABBR as ""Licensor Number"", " & _
"ag.AGREEMENTS_NAME as ""Project"" " & _
"from V_REPCUSTOMFIELDDATA cus " & _
"right join V_AGREEMENT ag " & _
"on cus.ASSOCIATED_WITH_INTERNAL_KEY = ag.CONTRACT_CODE " & _
"where " & _
"cus.INTERNAL_DESCRIPTIONS_CODE = 35 " & _
"and ag.AGREEMENTS_ABBR LIKE :licensorNum " & _
"and cus.FIELD_VALUE between " & _
"to_date(:sellOffStart, 'MM/DD/YY HH12:MI:SS AM') and to_date(:sellOffEnd, 'MM/DD/YY HH12:MI:SS AM') " & _
"order by " & _
"""Sell Off Date"", " & _
"""Licensor Number"""
Dim cmd As New OracleCommand(sql, conn)
cmd.Parameters.AddWithValue("licensorNum", "%" & Me.sellOffLicensorNum.Text & "%")
cmd.Parameters.AddWithValue("sellOffStart", Me.sellOffStart.Value.ToString())
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.
-
Apr 9th, 2008, 12:02 PM
#2
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
-
Apr 9th, 2008, 12:22 PM
#3
Thread Starter
Registered User
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|