Date Fields in VB 2005

T

Tony K

I have a form that involves a datagrid view to be filled after a start and
end date are selected from 2 DateTimePicker fields using the Short Format.
The query works without error but...

I have records to be returned that have dates such as 5/14/2008 and when the
start date is selected as 5/14/2008 the query doesn't include it unless I
select 5/13/2008.

I'm guessing this has to do with the time?? Is there a way to have it
ignore the time or make it the date + 12:00:00AM??


code:
Try
Me.TotalsTableAdapter.FillPOTotalByDate(Me.Inventory_management_databaseDataSet.Totals,
New System.Nullable(Of Date)(CType(StartDateTimePicker.Value, Date)), New
System.Nullable(Of Date)(CType(StopDateTimePicker.Value, Date)))

Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

query:
SELECT [Purchase Orders].OrderDate, [Purchase
Orders].PurchaseOrderNumber, Suppliers.SupplierName, SUM([Inventory
Transactions].UnitPrice)
AS [Sum Of UnitPrice]
FROM (([Purchase Orders] INNER JOIN
Suppliers ON [Purchase Orders].SupplierID =
Suppliers.SupplierID) INNER JOIN
[Inventory Transactions] ON [Purchase
Orders].PurchaseOrderID = [Inventory Transactions].PurchaseOrderID)
WHERE ([Purchase Orders].OrderDate >= ?) AND ([Purchase
Orders].OrderDate <= ?)
GROUP BY [Purchase Orders].OrderDate, [Purchase Orders].PurchaseOrderNumber,
Suppliers.SupplierName

Thank you,

Tony K
 
C

Cor Ligthert

Tony,

A DateTime structure is based on ticks in a long which starts at 01 01 00 .

As it is used as DateTime, then it contains a Date part and a Time part
which are given back in the format as is set in the local setting of the
computer.

However, as Steve wrote, you can select only the date part.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top