By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

DateTime in DataSet, want to display as Date (11/11/1111) type

P: n/a
I have an array being passed as a parameter to Crystal 9 (using vb .net in VS 2002). The listbox containing the dataset output at runtime shows DateTime format, but I want to only show mm/dd/yyyy format to the user. How is this accomplished? I changed the dataset type for the field to "Date" but it made no difference
Tks.
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Helen,

There's no really good way to store a date. It is either free text or
date/time. (Not until the next edition of SQL Server will we have a
seperate date data type.)

Until then, you might want to keep the data as it is in the data set. Then,
in the binding's parse and format events, use the Format(myText, "Short
Date") function to format the list box items.

Hope this helps...

Eric

"Helen" <an*******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
I have an array being passed as a parameter to Crystal 9 (using vb .net in VS 2002). The listbox containing the dataset output at runtime shows
DateTime format, but I want to only show mm/dd/yyyy format to the user. How
is this accomplished? I changed the dataset type for the field to "Date"
but it made no difference. Tks.

Nov 20 '05 #2

P: n/a
Hi Helen,

Have a look at this.
http://msdn.microsoft.com/library/de...ormattopic.asp

I hope this helps?

Cor
Nov 20 '05 #3

P: n/a
Thanks, Eric and Cor, but I'm still not resolving this. Here's my code
Private Sub ConfigureCrystalReports(
AReport = New A(
Dim myCrystalReportViewer = CrystalReportViewer

Dim myArrayList As ArrayList = New ArrayList(
myArrayList.Add("6/11/2001"
myArrayList.Add("1/31/2001"

ListBox1.DataSource = GetDefaultValuesFromParameterField(AReport
SetCurrentValuesForParameterField(A, myArrayList
myCrystalReportViewer.ReportSource = ARepor

End Su

Private Sub SetCurrentValuesForParameterField(ByVal myReportDocument As ReportDocument, ByVal myArrayList As ArrayList
Dim currentParameterValues As ParameterValues = New ParameterValues(
Dim submittedValue As Objec
For Each submittedValue In myArrayLis
Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue(
myParameterDiscreteValue.Value = submittedValue.ToString(
currentParameterValues.Add(myParameterDiscreteValu e
Nex

Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterField
Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER_FIELD_NAME
myParameterFieldDefinition.ApplyCurrentValues(curr entParameterValues
End Su

Private Function GetDefaultValuesFromParameterField(ByVal myReportDocument As ReportDocument) As ArrayLis
Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterField
Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER_FIELD_NAME
Dim defaultParameterValues As ParameterValues = myParameterFieldDefinition.DefaultValue

Dim myArrayList As ArrayList = New ArrayList(

Dim myParameterValue As ParameterValu
For Each myParameterValue In defaultParameterValue
If (Not myParameterValue.Kind.RangeValue) The
Dim myParameterDiscreteValue As ParameterDiscreteValue = CType(myParameterValue, ParameterDiscreteValue
myArrayList.Add(myParameterDiscreteValue.Value.ToS tring
End I
Nex
Return myArrayLis

End Functio

I'm not finding parse and format events for the bindings, Eric. How would I handle this
Thanks

Nov 20 '05 #4

P: n/a
Hi Helen,

I misreaded your message totally the firsttime,

Does this sample help you?

Cor
\\\
Dim dt As New DataTable("Helen")
dt.Columns.Add(New DataColumn("Dates", _
Type.GetType("System.DateTime")))
For i As Integer = 0 To 10
Dim dr As DataRow = dt.NewRow
dr("Dates") = CDate("01-01-2004").AddMonths(i)
dt.Rows.Add(dr)
Next
MessageBox.Show(CDate(dt.Rows(5)("Dates")).ToStrin g("MM-dd-yyyy"))
////
Nov 20 '05 #5

P: n/a
Hi, Cor:

I see this works, tks for the help. Can I bind a datatable to a listbox, just like a dataset, so then I can build your logic into the listbox?

I've started hardcoding the datasets and it seems more stable. I'd like to try your datatable concept.

Tks, Helen
Nov 20 '05 #6

P: n/a
Hi Helen,

Yes you can.
The listbox and combobox works both a little bit the same and I saw you
managed to do that, the both derive from listcontrol.

I hope this helps?

Cor
I see this works, tks for the help. Can I bind a datatable to a listbox, just like a dataset, so then I can build your logic into the listbox?

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.