473,395 Members | 1,629 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,395 software developers and data experts.

Different results if you have String or a Varient for Dates?

I have the following page as test.aspx:
************************************************** *
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDate %>.<br>
</center>
</body>
</html>
************************************************** *

If I have CurrentDate as String, like I do here, I get the following
page displayed:

The current date is 2/14/2004.

But if I take out the As String and have only "Dim CurrentDate", I get
the following result:

The current date is 2/14/2004 12:00:00 AM.

Why do I get the time for the Variant and not for the string?

Tom.

Jul 19 '05 #1
6 1640
Dim strDate
Dim valTime
Dim lBoth

strDate = Date()
valTime = Time()
lBoth = Now()

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
I have the following page as test.aspx:
************************************************** *
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDate %>.<br>
</center>
</body>
</html>
************************************************** *

If I have CurrentDate as String, like I do here, I get the following
page displayed:

The current date is 2/14/2004.

But if I take out the As String and have only "Dim CurrentDate", I get
the following result:

The current date is 2/14/2004 12:00:00 AM.

Why do I get the time for the Variant and not for the string?

Tom.

Jul 19 '05 #2


Steven Burn wrote:
Dim strDate
Dim valTime
Dim lBoth

strDate = Date()
valTime = Time()
lBoth = Now()
I understand the difference between these functions (which don't work in
asp.net, apparently). My problem is that I am using the same function
and get different results, depending whether the resulting variable is a
String or Variant.

Tom

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
I have the following page as test.aspx:
************************************************ ***
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDate %>.<br>
</center>
</body>
</html>
************************************************ ***

If I have CurrentDate as String, like I do here, I get the following
page displayed:

The current date is 2/14/2004.

But if I take out the As String and have only "Dim CurrentDate", I get
the following result:

The current date is 2/14/2004 12:00:00 AM.

Why do I get the time for the Variant and not for the string?

Tom.



Jul 19 '05 #3
Thomas Scheiderich wrote:
I have the following page as test.aspx:
************************************************** *
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDate %>.<br>
</center>
</body>
</html>
************************************************** *

If I have CurrentDate as String, like I do here, I get the following
page displayed:

The current date is 2/14/2004.

But if I take out the As String and have only "Dim CurrentDate", I get
the following result:

The current date is 2/14/2004 12:00:00 AM.

Why do I get the time for the Variant and not for the string?

Tom.

The Date datatype contains time as well as the date, just like in Access and
SQL Server. Dates are numbers with subType Double. the whole number
represents the number of days since the seed date, and the decimal portion
represents the time of day (.0 = midnight, .5 = noon). If you provide a date
without providing the time (which I guess is what the Today function is
doing), the date is stored as nnnnn.0. So when that date is written, the
"12:00 AM" is included.

Bob Barrows

PS. This is a classic asp newsgroup. .Net questions should be asked in the
appropriate "dotnet" newsgroup. There are several in that hierarchy.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4
Bob Barrows wrote:
Thomas Scheiderich wrote:
I have the following page as test.aspx:
************************************************ ***
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDate %>.<br>
</center>
</body>
</html>
************************************************ ***

If I have CurrentDate as String, like I do here, I get the following
page displayed:

The current date is 2/14/2004.

But if I take out the As String and have only "Dim CurrentDate", I get
the following result:

The current date is 2/14/2004 12:00:00 AM.

Why do I get the time for the Variant and not for the string?

Tom.
The Date datatype contains time as well as the date, just like in Access and
SQL Server. Dates are numbers with subType Double. the whole number
represents the number of days since the seed date, and the decimal portion
represents the time of day (.0 = midnight, .5 = noon). If you provide a date
without providing the time (which I guess is what the Today function is
doing), the date is stored as nnnnn.0. So when that date is written, the
"12:00 AM" is included.

I understand that and have no trouble with that.

What I am confused on is why we get different results, depending whether
the resulting variable is a String or Variant. I am assuming that the
time is being truncated for the String and not for the Variant. Why?

Bob Barrows

PS. This is a classic asp newsgroup. .Net questions should be asked in the
appropriate "dotnet" newsgroup. There are several in that hierarchy.


Jul 19 '05 #5
Thomas Scheiderich wrote:
Bob Barrows wrote:
Thomas Scheiderich wrote:
I have the following page as test.aspx:
************************************************** *
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDate %>.<br>
</center>
</body>
</html>
************************************************** *

If I have CurrentDate as String, like I do here, I get the following
page displayed:

The current date is 2/14/2004.

But if I take out the As String and have only "Dim CurrentDate", I
get
the following result:

The current date is 2/14/2004 12:00:00 AM.

Why do I get the time for the Variant and not for the string?

Tom.

The Date datatype contains time as well as the date, just like in
Access and SQL Server. Dates are numbers with subType Double. the
whole number represents the number of days since the seed date, and
the decimal portion represents the time of day (.0 = midnight, .5 =
noon). If you provide a date without providing the time (which I
guess is what the Today function is doing), the date is stored as
nnnnn.0. So when that date is written, the "12:00 AM" is included.

I understand that and have no trouble with that.

What I am confused on is why we get different results, depending
whether
the resulting variable is a String or Variant. I am assuming that the
time is being truncated for the String and not for the Variant. Why?


I have not started using .Net yet so I can't answer that question. If the
answer isn't in the documentation, then you should ask over at
..dotnet.framework.vbnet (I think that's what the group's name is ... )

My guess is that Today returns a string containing only the date, so when
assigned to a string variable, it only contains the date. When the value
returned from Today is converted to Date, the 12 AM is implied by the lack
of a time specification. Again: look it up in the documentation, or ask on
the vbnet group.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #6
hi, try to use formatdatetime function, the help follows:
FormatDateTime Function Language Reference
Version 2

See Also

Description
Returns an expression formatted as a date or time.
Syntax
FormatDateTime(Date[, NamedFormat])
The FormatDateTime function syntax has these parts:
PartDescription
DateRequired. Date expression to be formatted.
NamedFormatOptional. Numeric value that indicates the date/time format used.
If omitted, vbGeneralDate is used.

Settings
The NamedFormat argument has the following settings:
ConstantValueDescription
vbGeneralDate0Display a date and/or time. If there is a date part, display
it as a short date. If there is a time part, display it as a long time. If
present, both parts are displayed.
vbLongDate1Display a date using the long date format specified in your
computer's regional settings.
vbShortDate2Display a date using the short date format specified in your
computer's regional settings.
vbLongTime3Display a time using the time format specified in your computer's
regional settings.
vbShortTime4Display a time using the 24-hour format (hh:mm).

Remarks
The following example uses the FormatDateTime function to format the
expression as a long date and assign it to MyDateTime:
Function GetCurrentDate
' FormatDateTime formats Date in long date.
GetCurrentDate = FormatDateTime(Date, 1)
End Function

bye,
--
««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
"Thomas Scheiderich" <tf*@deltanet.com> escreveu na mensagem
news:40**************@deltanet.com...
I have the following page as test.aspx:
************************************************** *
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDate %>.<br>
</center>
</body>
</html>
************************************************** *

If I have CurrentDate as String, like I do here, I get the following
page displayed:

The current date is 2/14/2004.

But if I take out the As String and have only "Dim CurrentDate", I get
the following result:

The current date is 2/14/2004 12:00:00 AM.

Why do I get the time for the Variant and not for the string?

Tom.

Jul 19 '05 #7

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

Similar topics

72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
4
by: kinne | last post by:
The following code is supposed to reverse the date in "yyyy-mm-dd" format, but it produces different results in Firefox 1.0 and in Internet Explorer 6SP1. In Firefox, the result is correct...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
8
by: Thomas Scheiderich | last post by:
I have the following page as test.aspx: *************************************************** <html> <head> <title>Hello and Welcome Page</title> </head> <body> <center> <% Dim CurrentDate As...
24
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
9
by: Blarneystone | last post by:
Hi, I am using VB.NET and trying to pull data from two different tables in the database. I am using what I think is standard code. But the data I am pulling is like the following: Table1...
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
3
by: Bill Hutchison | last post by:
I have a query that returns different results (3508 rows for snapshot, 6288 for dynaset) and that is the only thing I change to get the different results. When I try to make a table from the...
0
by: billchalmers | last post by:
I am using sql 2005 express and I have a strange proble, when I execute a stored procedure from the query window I get the results I expect, but when I execute it from an asp page then I get a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
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...

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.