469,647 Members | 1,808 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

Date Fields in VB 2005

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.Invento ry_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

Oct 7 '08 #1
2 1256
Tony K wrote:
>
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??
Me.TotalsTableAdapter.FillPOTotalByDate(Me.Invento ry_management_databaseDataSet.Totals,
New System.Nullable(Of Date)(CType(StartDateTimePicker.Value, Date)),
You can get the date only part of a datetime as a property of the datetime
variable:
CType(StartDateTimePicker.Value, Date).Date

Oct 7 '08 #2
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
"Tony K" <my*********@kingprogramming.comschreef in bericht
news:1F**********************************@microsof t.com...
>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.Invento ry_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

Oct 7 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Si | last post: by
1 post views Thread by bafidi | last post: by
8 posts views Thread by Jeremy | last post: by
7 posts views Thread by Nicolae Fieraru | last post: by
5 posts views Thread by Helen R Martin | last post: by
3 posts views Thread by Glencannon4424 via AccessMonster.com | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.