[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3765
  • Last Modified:

How to check date is not dbnull

Hi,
I have a table with field type:datetime...
i retrieve its value from database
now if the date is null the value returned from database contains time and no date...if i check against
dbnull function it returns true even if the date is null as the field format is date and the value contains time ...how do i check for null date.


Regards.
0
anusdesai
Asked:
anusdesai
  • 3
1 Solution
 
Ashish PatelCommented:
very simple while fetching the datetime column name, covert that column to have just date and not time like below

select convert(datetime, COLUMNNAME, 101) from TABLENAME and check with either dbNull or "" (blank)
0
 
ee_rleeCommented:
use isnull(mydate)
0
 
Ashish PatelCommented:
sorry try using this

select convert(varchar(10), COLUMNNAME, 101) FROM TABLENAME
0
 
anusdesaiAuthor Commented:
Hi asvforce,
Cant change the query....can i check on the result
0
 
Ashish PatelCommented:
Yes by using the Format function on the resulting field you can do that, just try fetching "m/dd/yyyy" and if its blank or "1/1/1900" that means there is no date.
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

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