473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1860
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","p aram1","param_v alue")

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

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

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

iQA/AwUBQtFnhoechKq OuFEgEQKCUACgi/eDbd0MOiwayA02t G2sn09dghUAoPLU
I7L6mkiZUM7HAM8 dw6Yq97GY
=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**@NorthStat e.net> wrote in
news:lk******** *************** *********@4ax.c om:
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**@NorthStat e.net> wrote in
news:s2******** *************** *********@4ax.c om:
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**@NorthStat e.net> wrote in message
news:m5******** *************** *********@4ax.c om...
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
5219
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 appreciated. TIA
0
3241
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 schemaLocation="C:\Faster\App\Demo\DataTypes\login.xsd" /> <xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\password.xsd" /> - <xsd:complexType name="userloginType"> - <xsd:all>
17
760
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
3438
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
5058
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
1309
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, views, and foreign keys before. Any recommended books or websites (or exercises) that would really help someone get to know not just the basics of how these advanced features work, but some real in-depth insight into how to USE them for real work?
10
2185
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 I am doing is quering the db for all the headers for a certain group and then going through them to find all the parts of each post. I only want ones that are complete. Meaning all segments for that one file posted are there. using System;
11
5276
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 development which is fine and sysnchronisation back and forth is working as expected. The problem I am having is with the DATE type (implemented using an 8-byte floating-point number. Days are represented by whole number increments starting with...
3
4414
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. Occasionally though, I need to change the "As Of Date" to some date in the past, and then when I run the queries, they're based on that date in the past. This generally works fine, but, sometimes, the date gets reset to something WAY in the past...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9944
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.