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

From: Vilmar Brazão de Oliveira (teste_at_teste.teste.teste)
Date: 02/16/04


Date: Mon, 16 Feb 2004 09:47:39 -0300

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" <tfs@deltanet.com> escreveu na mensagem
news:402F04C2.9010205@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.
>


Relevant Pages

  • Re: Format an Excel Column in the windows short date format.
    ... Dim Buffer As String, Ret As Long ... Dim GetInfo As String ... It works for most regional settings but not Norwegian. ... If anyone can point me in the right direction on how to format a column ...
    (microsoft.public.excel.programming)
  • Re: Regional settings cause runtime crash
    ... converting variable types. ... I'm declaring a variable as a string which equals a line from the ... format, i.e. date values in DateTime variables etc. ... To present data to the user, use the regional settings that are ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Format an Excel Column in the windows short date format.
    ... I display the same string. ... Dim GetInfo As String ... It works for most regional settings but not Norwegian. ... using the NumberFormatLocal format produced the same result. ...
    (microsoft.public.excel.programming)
  • Re: Format an Excel Column in the windows short date format.
    ... I mean the format string used is correctly assigned as "dd.MM.yyyy" and the ... Dim GetInfo As String ... It works for most regional settings but not Norwegian. ...
    (microsoft.public.excel.programming)
  • Re: Number formats problems
    ... string, and this is causing FormatNumber to try and convert it to a proper ... If you want to format the final string representation of your number with a ... FormatNumber will always acknowledge the user's regional settings ... > dim a as String ...
    (microsoft.public.vb.general.discussion)