473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can someone tell me what the significant difference between Date and Variant datatypes is?

MLH
If I choose to dim MyDate as Date or MyDate as Variant,
what is the most significant difference between the two
choices?
Nov 13 '05 #1
8 1835
MLH wrote:
If I choose to dim MyDate as Date or MyDate as Variant,
what is the most significant difference between the two
choices?


Variant can be anything (including a date) but it may interest you to
know that a variant can be null whereas a date cannot. Important if you
read values from a table (which can have nulls in).

--
[OO=00=OO]
Nov 13 '05 #2
MLH wrote:
If I choose to dim MyDate as Date or MyDate as Variant,
what is the most significant difference between the two
choices?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Date data type takes up 8 bytes in memory/storage and Variant can take
up to 16 bytes for numerics (that includes dates, since a date is stored
as a Double).

It's better to use a Date data type if you know that the data will
always be a date. I usually use Variants when I'm not sure if the
returned value from a query will be NULL or the data type I expect.
E.g.:

Dim varReturn As Variant

' run a routine that returns the result of a query:
varReturn = getQueryResult("query_name","param1","param_value" )

If IsNull(varReturn) Then
MsgBox "No Data Fits Your Criteria"
Else
' do something w/ the returned value
End If

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQtFnhoechKqOuFEgEQKCUACgi/eDbd0MOiwayA02tG2sn09dghUAoPLU
I7L6mkiZUM7HAM8dw6Yq97GY
=xRKd
-----END PGP SIGNATURE-----
Nov 13 '05 #3
MLH
Many thanks to you both. Very good information.
I didn't have Date datatype in Access 2.0 so I
wasn't familiar with it at all.
Nov 13 '05 #4
MLH <CR**@NorthState.net> wrote in
news:lk********************************@4ax.com:
Many thanks to you both. Very good information.
I didn't have Date datatype in Access 2.0 so I
wasn't familiar with it at all.


You shouldn't have used variant for dates in Access 2, but double as
your datatype, since that's what a data actually is, a double with
restrictions on allowed values. This is just as Boolean is an
integer with a restricted set of allowed values.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5
MLH
Good point, I agree. Speaking of Boolean, why did MS make it so
big? We're only talking -1 and 0. Couldn't they have made it Byte
sized?

You shouldn't have used variant for dates in Access 2, but double as
your datatype, since that's what a data actually is, a double with
restrictions on allowed values. This is just as Boolean is an
integer with a restricted set of allowed values.


Nov 13 '05 #6
MLH <CR**@NorthState.net> wrote in
news:s2********************************@4ax.com:
You shouldn't have used variant for dates in Access 2, but double
as your datatype, since that's what a data actually is, a double
with restrictions on allowed values. This is just as Boolean is an
integer with a restricted set of allowed values.


Good point, I agree. Speaking of Boolean, why did MS make it so
big? We're only talking -1 and 0. Couldn't they have made it Byte
sized?


Actually, you're right -- it may be a Byte field. I was thinking
backwards to Access 2 days, when we had to use integer fields for it
(not having a Byte data type back then).

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7
MLH
I can't remember where I was reading just a couple of days ago, but
something there suggested to me it was two bytes in size in A97. I
thought that a waste of space. Granted, its not much, but hey...


Actually, you're right -- it may be a Byte field. I was thinking
backwards to Access 2 days, when we had to use integer fields for it
(not having a Byte data type back then).


Nov 13 '05 #8
I believe I remember that the 2-byte word gives better performance and can
be used in calculations in ways that a smaller value could not. Bytes, it
appears are (mostly) for containing characters, integers and longs are
(mostly) for doing calculation.

Larry Linson

"MLH" <CR**@NorthState.net> wrote in message
news:m5********************************@4ax.com...
I can't remember where I was reading just a couple of days ago, but
something there suggested to me it was two bytes in size in A97. I
thought that a waste of space. Granted, its not much, but hey...


Actually, you're right -- it may be a Byte field. I was thinking
backwards to Access 2 days, when we had to use integer fields for it
(not having a Byte data type back then).

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
0
by: wooks | last post by:
<?xml version="1.0" ?> - <xsd:schema targetNamespace="urn:faster:userlogin" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:faster:userlogin"> <xsd:include...
17
by: Nathan Given | last post by:
Hello All, I am trying to debug a broken query. The query uses Left$(,4) instead of Left(,4). What is the difference between the Left() and Left$() functions in Microsoft Access? Thanks!...
41
by: Mountain Bikn' Guy | last post by:
What is the current preferred way to save user preferences in dotnet? Is the registry the right place to do this? Can anyone recommend a good article (or book) for this topic? Thanks.
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
5
by: Miles Keaton | last post by:
I'm switching to PostgreSQL from MySQL. Using the SAMs book called PostgreSQL which has been great to skim the surface of the differerences. I had never even heard of things like triggers,...
10
by: Extremest | last post by:
I know there are ways to make this a lot faster. Any newsreader does this in seconds. I don't know how they do it and I am very new to c#. If anyone knows a faster way please let me know. All...
11
by: jwf | last post by:
I am writing a NON MFC C++ application (Plug-in for a 3rd party DB system). The application is designed to synchronise data between MS Outlook and the DB system. I am using smart pointers for the...
3
by: murch.alexander | last post by:
I made a simple public function to set and return a date value (see below). I have a number of queries that call up the function to get the "As Of Date," which is typically set to today's date....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.