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

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Bob Barrows (reb01501_at_NOyahoo.SPAMcom)
Date: 02/15/04


Date: Sun, 15 Feb 2004 09:38:02 -0500

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"


Relevant Pages

  • Re: Different results if you have String or a Varient for Dates?
    ... This is a VB.net newsgroup. ... > Dim CurrentDate As String ... > Why do I get the time for the Variant and not for the string? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: string to array
    ... resides in a string, why not use the InStrmethod? ... how can I convert this string into array so that I get the values ... Please reply to the newsgroup. ... header is my spam trap, so I don't check it very often. ...
    (microsoft.public.scripting.vbscript)
  • Re: Query help: What is the best and most efficient way to do this
    ... >> What's the best and most efficient way to string these data into ... > header is my spam trap, so I don't check it very often. ... > quicker response by posting to the newsgroup. ...
    (microsoft.public.sqlserver.programming)
  • Re: Outlook Express question
    ... IMproper string. ... Post replies to the newsgroup. ... @="Microsoft Outlook Express 6" ... >>> Jim Carlock ...
    (microsoft.public.windowsxp.general)
  • Re: Outlook Express question
    ... IMproper string. ... Post replies to the newsgroup. ... @="Microsoft Outlook Express 6" ... >>> Jim Carlock ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)