-
November 28th, 1999, 11:54 AM
#1
How to make a date Variable empty ?
How can I make a date variable assigned empty like we do with strings by setting ""
-
November 28th, 1999, 12:39 PM
#2
Re: How to make a date Variable empty ?
Hi,
Use NULL to assing a blank in date field.
or alternatively -
in INSERT INTO statement do not include the date fields, it will automatically be blank.
Santulan
-
November 29th, 1999, 04:47 AM
#3
Re: How to make a date Variable empty ?
My problem is as below regarding dates
Dim StartDate as Date
StartDate = #10/01/1999#
...
...
...
Now I want to make the variable empty
I tried to issue null
StartDate = Null
'' Giving Error
Check out this
-
November 29th, 1999, 04:56 AM
#4
Re: How to make a date Variable empty ?
-
November 29th, 1999, 11:23 AM
#5
Re: How to make a date Variable empty ?
In access if you update and set date = "" date gets blank.
or you try vbNull
Santulan
-
December 16th, 2010, 01:38 PM
#6
Re: How to make a date Variable empty ?
I realize I'm writing this 11 years after the initial query, but the advice given is erroneous, and so I'm adding this so others who see this page are not misled. vbNull is intended strictly for use with the VarType() function to test if a variable is Null, as follows:
If VarType(abc) = vbNull Then
You cannot use vbNull to set a variable to Null. Indeed, if you try it, like so:
abc = vbNull
then the variable will actually be assigned a value of 1 (or "1" if it's a string variable). So if you do that then obviously an IsNull() test would fail to work properly because the variable is not null.
My understanding is that for a code variable you can't actually assign a Null to it unless it's a Variant data type (unlike an Access table field, which you can assign as Null). So a string variable must be assigned as empty string and a numeric must be assigned zero (or whatever else you want to used to signify as "unassigned" in the logical context of your code), like so:
str = ""
num = 0
-
December 16th, 2010, 05:18 PM
#7
Re: How to make a date Variable empty ?
Why dig up long-dead posts?
-
August 27th, 2013, 08:43 AM
#8
Re: How to make a date Variable empty ?
Reply to Your Query - Solved
If you declare any variable as date format, it will the data like as "00:00:00".
So before execute your sql command , please verify the contents in the date varaible as follws
If isdate(Var_date) = True or Var_date <> "00:00:00" Then
Tablename!Fieldname = Var_Date
else
TableName!FieldName =Empty
End if
recordset.update
I tried the above method, it works with MsAccess and MSSQL too
Thank You
-
August 28th, 2013, 01:31 AM
#9
Re: How to make a date Variable empty ?
I just can't understand why someone would register on a site to replay to a question that was asked 14 years ago ???
Always use [code][/code] tags when posting code.
-
June 27th, 2019, 12:20 PM
#10
Re: How to make a date Variable empty ?
Originally Posted by DataMiser
I just can't understand why someone would register on a site to replay to a question that was asked 14 years ago ???
Agreed, makes no sense to me. :-)
-
June 27th, 2019, 01:08 PM
#11
Re: How to make a date Variable empty ?
Two negatives don't always result in a positive!
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|