Creating an Optional Date Parameter

  • Thread starter Learning SQL Server
  • Start date
L

Learning SQL Server

What should the default value for an optional Date parameter be in a
function if I want it to default to Nothing?

Setting the optional value to "" fails, so does setting it to Nothing.

Function blah(byval User as string, Optional byval UserDate as Date = ?????)

Thanks (again)
 
R

Russell Jones

Use DateTime.MinValue, and then check to make sure the passed value is
greater than that inside the function body.
 

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