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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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 said:
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.
 
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(myParameterDiscreteValue
Nex

Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterField
Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER_FIELD_NAME
myParameterFieldDefinition.ApplyCurrentValues(currentParameterValues
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.ToString
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
 
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")).ToString("MM-dd-yyyy"))
////
 
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
 
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?
 
Back
Top