• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

Datetimepicker Dates and SQL Server Format

Hi,

I have a VB application form with two datetimepickers, Datagrid and Button. The user is to select a start date and end date using the datetimepickers. Once selected,  on click of the button a query is sent to the SQL server database table to return entries between these dates and populate the Datagrid with results.

If I select between dates 05/07/2006 and 07/07/2006 - I also get entries starting from 25/05/2006.

There seems to be a problem between dd(days) and MM(months) using dd as MM.

I have the DateTimePickers format set to Custom and CustomFormat as dd/MM/yyyy

Entries in the table being query also follow this format dd/mm/yyyy.

Can anyone tell me what is happening here, I only want entries from the selected dates.

Here is my SQL Command

SELECT * WHERE MdnMaster.ActualDeliveryDate BETWEEN '" & DTP_StartDate.Value & "' AND '" & DTP_EndDate.Value & "'", cn)

 
0
daly__paul
Asked:
daly__paul
1 Solution
 
SanclerCommented:
.Value is still in MM/dd/yyyy format.  What your custom formatting does is alter what is displayed into dd/MM/yyyy format.  The easiest way is to use DTP_StartDate.Text and DTP_EndDate.Text in your Select command.

Roger
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now