Sql date is null or empty




















It only takes a minute to sign up. Connect and share knowledge within a single location that is structured and easy to search. The following piece of code is returning when the DOB field is null. I wanted and expected it to return an empty string '' but it's not. How should I proceed to get my desired results?

If you're checking whether or not the value is NULL , there is no need to convert it to a date, unless you wanted to return a date value which you don't seem to. An empty string, on the other hand, evaluates to 0 , which in SQL Server is implicitly an integer representing the number of days since Sign up to join this community.

The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? The cookie is used to store the user consent for the cookies in the category "Analytics". The cookies is used to store the user consent for the cookies in the category "Necessary".

The cookie is used to store the user consent for the cookies in the category "Other. The cookie is used to store the user consent for the cookies in the category "Performance". It does not store any personal data. Functional Functional. Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features. Performance Performance.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors. Analytics Analytics. Analytical cookies are used to understand how visitors interact with the website.

These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc. Advertisement Advertisement. Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads. Others Others. Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet. Did you know? ETL by more than 30x. Online course weekend offer!

Lifetime access , live demonstrations, downloadable resources and more. The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". T-SQL's Isnull var1, 'value' doesn't. Praveen Nambiar Praveen Nambiar 4, 1 1 gold badge 20 20 silver badges 31 31 bronze badges. John Woo John Woo k 63 63 gold badges silver badges bronze badges. As Xavier points out, there is no need to do BOTH ltrim and rtrim if the goal is merely to compare to empty string.

For example, you don't care whether the comparison fails because what remains is "abc" or " abc". Enamul Hassan 4, 23 23 gold badges 36 36 silver badges 53 53 bronze badges. Scott Sterling Scott Sterling 81 1 1 silver badge 2 2 bronze badges. Community Bot 1 1 1 silver badge. Martin Smith Martin Smith k 81 81 gold badges silver badges bronze badges. Zaheer Ahmed Anouar Mokhtari Anouar Mokhtari 1, 3 3 gold badges 21 21 silver badges 23 23 bronze badges.

The isnull function literally just checks if the value is null. It will not work if the string is empty " ". Max Pringle. I do not state differently.

Also the provided code address the question request. Not sure on your contribution. Suggest an edit instead of downvoting. I put in a suggested edit now. This where clause only gets the null values not the empty string values. A nullif could be used to get the empty values. Biniam Eyakem Biniam Eyakem 5 5 silver badges 17 17 bronze badges.



0コメント

  • 1000 / 1000