With Date one day less

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

With Date one day less

Gianluigi
I, with Date, become crazy.
Just look here:
'---------------------------------
Public Sub Main()

  Dim d1 As Date

  d1 = "6/15/2008"
  Print Format$(d1, "dd mm yyyy") ' > 14 06 2008

End
'----------------------------------
Because UTC (an hour more) becomes one less day?
(sig!)

Regards
Gianluigi
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: With Date one day less

Karl Reinl
Am Samstag, den 21.01.2017, 17:22 +0100 schrieb Gianluigi:

> I, with Date, become crazy.
> Just look here:
> '---------------------------------
> Public Sub Main()
>
>   Dim d1 As Date
>
>   d1 = "6/15/2008"
>   Print Format$(d1, "dd mm yyyy") ' > 14 06 2008
>
> End
> '----------------------------------
> Because UTC (an hour more) becomes one less day?
> (sig!)
>
> Regards
> Gianluigi

Salut Gianluigi,

like that you get what you want.

Public Sub Button1_Click()
Dim d1 As Date

  d1 = Date(2008, 6, 15)
  Print Format$(d1, "dd mm yyyy") ' > 15 06 2008

End


--
Amicalement
Charlie


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: With Date one day less

Gianluigi
Hi Charlie,

I thank for the answer and will do so too.
But my poor mind cannot comprehend the question of time zone.

Regards
Gianluigi


2017-01-21 17:51 GMT+01:00 Karl Reinl <[hidden email]>:

> Am Samstag, den 21.01.2017, 17:22 +0100 schrieb Gianluigi:
> > I, with Date, become crazy.
> > Just look here:
> > '---------------------------------
> > Public Sub Main()
> >
> >   Dim d1 As Date
> >
> >   d1 = "6/15/2008"
> >   Print Format$(d1, "dd mm yyyy") ' > 14 06 2008
> >
> > End
> > '----------------------------------
> > Because UTC (an hour more) becomes one less day?
> > (sig!)
> >
> > Regards
> > Gianluigi
>
> Salut Gianluigi,
>
> like that you get what you want.
>
> Public Sub Button1_Click()
> Dim d1 As Date
>
>   d1 = Date(2008, 6, 15)
>   Print Format$(d1, "dd mm yyyy") ' > 15 06 2008
>
> End
>
>
> --
> Amicalement
> Charlie
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: With Date one day less

Benoît Minisini
Le 21/01/2017 à 19:22, Gianluigi a écrit :
> Hi Charlie,
>
> I thank for the answer and will do so too.
> But my poor mind cannot comprehend the question of time zone.
>
> Regards
> Gianluigi
>
>

If you convert a string to a date, then the string is assumed to be an
UTC time, *not* a local time.

To convert a local time as a string to a date, you must use the Val()
function. Or, as Karl said, you can use the Date() function if you have
the date split into its different components.

It's exactly the same with numbers!

CStr() and CFloat() assume the american format (which is like "UTC" for
numbers).

Str() and Val() assume the local format.

Regards,

--
Benoît Minisini

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: With Date one day less

Gianluigi
Hi Benoit,
You are always very kind, your explanation has allowed me to understand.

The string data is assumed at 00:00:00 and therefore one hour back from the
day before.
If I had written
'---------------------------------
Public Sub Main()

  Dim d1 As Date

  d1 = "6/15/2008 01:00:00"
  Print Format$(d1, "dd mm yyyy") ' > 15 06 2008

End
'----------------------------------
I got the right date being an hour ahead of us.

Thank you very much
Regards

Gianluigi

2017-01-21 19:34 GMT+01:00 Benoît Minisini <[hidden email]>:

> Le 21/01/2017 à 19:22, Gianluigi a écrit :
> > Hi Charlie,
> >
> > I thank for the answer and will do so too.
> > But my poor mind cannot comprehend the question of time zone.
> >
> > Regards
> > Gianluigi
> >
> >
>
> If you convert a string to a date, then the string is assumed to be an
> UTC time, *not* a local time.
>
> To convert a local time as a string to a date, you must use the Val()
> function. Or, as Karl said, you can use the Date() function if you have
> the date split into its different components.
>
> It's exactly the same with numbers!
>
> CStr() and CFloat() assume the american format (which is like "UTC" for
> numbers).
>
> Str() and Val() assume the local format.
>
> Regards,
>
> --
> Benoît Minisini
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Loading...