473,607 Members | 2,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 <%=CurrentDat e %>.<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 1650
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.c om> 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 <%=CurrentDat e %>.<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.c om> wrote in message
news:40******** ******@deltanet .com...
I have the following page as test.aspx:
************* *************** *************** ********
<html>
<head>
<title>Hell o and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDat e %>.<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 <%=CurrentDat e %>.<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>Hell o and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
CurrentDate = Today
%>
The current date is <%=CurrentDat e %>.<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 <%=CurrentDat e %>.<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.framew ork.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.
NamedFormatOpti onal. Numeric value that indicates the date/time format used.
If omitted, vbGeneralDate is used.

Settings
The NamedFormat argument has the following settings:
ConstantValueDe scription
vbGeneralDate0D isplay 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.
vbLongDate1Disp lay a date using the long date format specified in your
computer's regional settings.
vbShortDate2Dis play a date using the short date format specified in your
computer's regional settings.
vbLongTime3Disp lay a time using the time format specified in your computer's
regional settings.
vbShortTime4Dis play 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.c om> 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 <%=CurrentDat e %>.<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
5184
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 complete in connection with attendance at a seminar. After spending more than 15 minutes on it, I clicked on the submit button - and nothing happened. Looking round the pages on Javascript form validation that Google produced for me (well,...
4
2421
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 ("2004-11-29") but it's wrong in Internet Explorer 6SP1 ("00:20:15-11-29"). If I change "dateParts" to "dateParts", it's exactly the opposite that occures: a correct result in IExplorer but a fault in Firefox. Is there a workaround? Where do I miss the...
12
6362
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 ranges, ie between 24/09/2004 and 01/10/2004 together with 05/10/2004 and 07/10/2004 ? If I enter the "Between" criteria on different lines it returns no data.
8
1120
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 String
24
19896
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 renewal in the history of the policyholder. The information is in 2 tables, policy and customer, which share the custid data. The polno changes with every renewal Renewals in 2004 would be D, 2005 S, and 2006 L. polexpdates for a given customer...
9
1569
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 Column1 Row1 Table2 Column1 Row1 ~ 20 Table1 Column1 Row2 ~ 3
21
3365
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 USA is mm/dd/yyyy and mexico is dd/mm/yyyy. So, with the computer set to mexico, any standard CDATE function is going to return the date in the dd/mm/yyyy setting since that is what the computer is set to. I want to be able to enter a date in...
3
3634
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 query, it makes 3508 rows. I also know that there are 6288 unique rows in the results. Is there some configuration choice that is causing the snapshot version to return the wrong row count? Thanks for your help on this one. If it wasn't that the...
0
1236
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 slightly different result. My stored procedure accepts a start date and a Day of week, it then gets the date of the next date that falls on that day, it is for clinic generation, it does an insert into a clinic table, if I pass in the following params ...
0
8463
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8322
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
6803
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
5997
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
5471
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
3953
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
4013
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2461
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
1
1574
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.