Sqldatasource parameter date

  • Thread starter Thread starter SMXBob
  • Start date Start date
S

SMXBob

I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors less
than that date. But I can't figure out how to reset it so every record comes
back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.

Thanks for any suggestionsk
 
I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors less
than that date. But I can't figure out how to reset it so every record comes
back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.

Thanks for any suggestionsk

I think you can set the date of tomorrow to show all records.
 
SMXBob said:
I have a slight problem resetting a date select parameter in that I
can't get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

If you want to include the null ones, then surely you'd want to include them
in the predicate:

SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm OR [DueDate] IS
NULL)
 
Please notice what I am trying to do here.

If I set the DueDateParm to a date I get all the records less then that date
(see my query).
The result set does NOT include nulls which is how it is suppose to work.

What I then want is the option to return all rows including nulls.
The OR option would work but I am back to my initial problem how do I remove
it when I want just my date selection.
 
SELECT * FROM [MyTable]
WHERE ([DueDate] < @DueDateParm) Or (@DueDateParm Is Null)

SMXBob said:
Please notice what I am trying to do here.

If I set the DueDateParm to a date I get all the records less then that
date (see my query).
The result set does NOT include nulls which is how it is suppose to work.

What I then want is the option to return all rows including nulls.
The OR option would work but I am back to my initial problem how do I
remove it when I want just my date selection.



SMXBob said:
I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors less
than that date. But I can't figure out how to reset it so every record
comes back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.
 
Thanks Paul

I don't think I would have ever thought of that one.

Good job!


Paul Shapiro said:
SELECT * FROM [MyTable]
WHERE ([DueDate] < @DueDateParm) Or (@DueDateParm Is Null)

SMXBob said:
Please notice what I am trying to do here.

If I set the DueDateParm to a date I get all the records less then that
date (see my query).
The result set does NOT include nulls which is how it is suppose to work.

What I then want is the option to return all rows including nulls.
The OR option would work but I am back to my initial problem how do I
remove it when I want just my date selection.



SMXBob said:
I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors
less than that date. But I can't figure out how to reset it so every
record comes back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.
 
Back
Top