Results 1 to 7 of 7

Thread: Datetime

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Datetime

    How i display the time by day/month/year?

    thanks in advance.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Re: Datetime

    i have used Date(), but it set date with slahes how i set it like this dd-mm-yyyy?

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Datetime

    Have a look at the Format() method
    https://docs.microsoft.com/en-us/off...r-applications

  4. #4
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: Datetime

    Quote Originally Posted by hamon View Post
    i have used Date(), but it set date with slahes how i set it like this dd-mm-yyyy?
    Show your code, and I will tweak it

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Datetime

    Quote Originally Posted by hamon View Post
    i have used Date(), but it set date with slahes
    No, it doesn't. Date type data is not a String, it's a date and time represented as a double precision real number (float) basically identical internally to VB's Double type. There are no bits of text with punctuation.

    We'd have to see what you are doing with Date typed data. I'd guess something like relying on implicit coercion to convert it to String.

  6. #6
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    759

    Re: Datetime

    Quote Originally Posted by hamon View Post
    i have used Date(), but it set date with slashes ...
    Here's a slightly unexpected, Unwritten Rule about Dates:

    Dates have no format.

    (None any that you or I need to worry about, anyway).

    If you think they do, then you're almost always working with a String, not a Date.

    Quote Originally Posted by hamon View Post
    ... how i set it like this dd-mm-yyyy?
    With the Format$() function.

    Code:
    Dim dtNow as Date 
    Dim sNow as String 
    
    dtNow = Date() 
    sNow = Format$( dtNow, "dd-mm-yyyy" )
    Code:
    Debug.Print sNow
    03-03-2021
    
    Debug.Print dtNow
    2021.03.02          <-- your machine's local date format (locale).
    Regards,
    Phill W.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Re: Datetime

    Already done anyway thank you Phill W.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width