Alex
Alex

Reputation: 207

Access DB says my datetime is wrong

"SELECT Dateipfad FROM Attribute WHERE FS = '290' AND Letztes_mal_bearbeitet <= '15.11.2011 11:06:58'"

The datetimeValue is from a datetimepicker

Upvotes: 2

Views: 125

Answers (5)

iDevlop
iDevlop

Reputation: 25262

Agree with LassV. Karlsen suggestion. http://msdn.microsoft.com/en-us/library/aa160564(v=office.11).aspx

Upvotes: 1

Dariusz Tarczynski
Dariusz Tarczynski

Reputation: 16711

To match a particular date type the date enclosed by hash marks. Try to use:

SELECT Dateipfad FROM Attribute WHERE FS = '290' AND Letztes_mal_bearbeitet <= #15/11/2011 11:06:58#;

Upvotes: 1

Nighil
Nighil

Reputation: 4129

add this while loading the form

datetimepicker.Format = DateTimePickerFormat.Custom;
    datetimepicker.CustomFormat = "dd/MM/yyyy";

Upvotes: 1

Shadow Wizard
Shadow Wizard

Reputation: 66389

The correct way:

string strSQL = "SELECT Dateipfad FROM Attribute WHERE FS = '290' AND Letztes_mal_bearbeitet <= @date"
OleDbCommand command = new OleDbCommand(strSQL, oConnection);
command.Parameters.AddWithValue("@date", myDateTimePicker.Value);
//execute same way like you did before...

Upvotes: 3

il_guru
il_guru

Reputation: 8508

Change the . (dot) in the values with slash /

SELECT Dateipfad FROM Attribute WHERE FS = '290' AND Letztes_mal_bearbeitet <= '15/11/2011 11:06:58'

Upvotes: 1

Related Questions