[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sString = Date(hBlah) returns 11pm


If you know the format of the date sString gets and it doesn't change (ie
you're not changing locales) then you can also do:

sString = Replace(str(Date(Now)),"  00:00:00","")

After that: Print sString

will only print the date.

On Fri, Apr 12, 2024 at 6:06 PM Bruce Steers <bsteers4@xxxxxxxxx> wrote:

>
>
> On Fri, 12 Apr 2024 at 23:18, Benoît Minisini <
> benoit.minisini@xxxxxxxxxxxxxxxx> wrote:
>
>> Le 12/04/2024 à 22:52, Bruce Steers a écrit :
>> >
>> > Not long ago using the following...
>> >
>> > Dim sString as String
>> > sString = Date(Now)
>> > Print sString
>> >
>> > Would print the date without the time
>> >
>>
>> No.
>>
>> Date(Now) moves its date argument to midnight in the current local time.
>>
>> Affecting that date to a string variable converts it using CStr(), which
>> will print the date in UTC time (and so with a time unless your local
>> time is the UTC time).
>>
>> It's `Print Date(Now)` or `sString = Str(Date(Now))` that will print a
>> date at midnight (or without time).
>>
>> Regards,
>>
>> --
>> Benoît Minisini.
>>
>
> it is now always printing with time as 00:00:00 using sString =
> Str(Date(Now))
>
> But On 9th Feb (when i altered the wiki) assigning it to a string even
> without Str() omitted the time completely.
> Now, oddly, only the Split(Date(Now), " ")[0] method works to omit the
> time text,
>
> Respects
> BruceS
>
>

Follow-Ups:
Re: sString = Date(hBlah) returns 11pmJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
References:
sString = Date(hBlah) returns 11pmBruce Steers <bsteers4@xxxxxxxxx>
Re: sString = Date(hBlah) returns 11pmBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: sString = Date(hBlah) returns 11pmBruce Steers <bsteers4@xxxxxxxxx>