DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Re: Date in this format (DD-MM-YYYY).

  1. #1
    AL KHALIFA Guest

    Re: Date in this format (DD-MM-YYYY).


    Sorry about this. Here is the complete post.

    Hi all,

    I need to capture the date from my PC.

    I used the following code:

    Dim PcDate As Date

    PcDate = Now()

    However, the variable PcDate returns the following:

    9/8/2002 10:10:00AM

    My question is:

    How to obtain the system date in the following format (DD-MM-YYYY) only?
    The time is not required in this application.


    Please help.

    Thanks in advance.

    AL KHALIFA




  2. #2
    Adeem Zashir Guest

    Re: Date in this format (DD-MM-YYYY).


    Hi,
    You just need to Replace your statement
    PcDate = Now()

    with this one

    PcDate = Format(Date,"DD-MM-YYYY")


    Regards...

    M. Kashif Javaid

    "AL KHALIFA" <salah@digitallinx.net> wrote:
    >
    >Sorry about this. Here is the complete post.
    >
    >Hi all,
    >
    >I need to capture the date from my PC.
    >
    >I used the following code:
    >
    >Dim PcDate As Date
    >
    >PcDate = Now()
    >
    >However, the variable PcDate returns the following:
    >
    >9/8/2002 10:10:00AM
    >
    >My question is:
    >
    >How to obtain the system date in the following format (DD-MM-YYYY) only?
    >The time is not required in this application.
    >
    >
    >Please help.
    >
    >Thanks in advance.
    >
    >AL KHALIFA
    >
    >
    >



  3. #3
    Arthur Wood Guest

    Re: Date in this format (DD-MM-YYYY).


    The Now() function is just that NOW - to the second. If all you want is the
    Date, without worrying about what time it is, then use the Date() function.
    The returned value can then be formatted as you want it, uing the Format$
    function.

    Remembe, however, that Date values in VB are INTERNALLY held as NUMBERS (
    a special type of DOUBLE), where the Integer part of the Number is the NUMBER
    of DAYS since 12/31/1899, and the fractional part of the Number is the fraction
    of 1 24-hour day( as measured in milliseconds), so that 12:00 NOON would
    be represented as 0.5

    Arthur Wood



    "AL KHALIFA" <salah@digitallinx.net> wrote:
    >
    >Sorry about this. Here is the complete post.
    >
    >Hi all,
    >
    >I need to capture the date from my PC.
    >
    >I used the following code:
    >
    >Dim PcDate As Date
    >
    >PcDate = Now()
    >
    >However, the variable PcDate returns the following:
    >
    >9/8/2002 10:10:00AM
    >
    >My question is:
    >
    >How to obtain the system date in the following format (DD-MM-YYYY) only?
    >The time is not required in this application.
    >
    >
    >Please help.
    >
    >Thanks in advance.
    >
    >AL KHALIFA
    >
    >
    >



  4. #4
    AL KHALIFA Guest

    Re: Date in this format (DD-MM-YYYY).


    Thanks guys!

    it works like this:

    PcDate = Format(Date, "DD-MM-YYYY")
    Label26.Caption = PcDate



    Thanks all

    AL KHALIFA


  5. #5
    Bob Butler Guest

    Re: Date in this format (DD-MM-YYYY).

    "AL KHALIFA" <salah@digitallinx.net> wrote in message
    news:3d53bb4f$1@10.1.10.29
    > Thanks guys!
    >
    > it works like this:
    >
    > PcDate = Format(Date, "DD-MM-YYYY")
    > Label26.Caption = PcDate


    In your original post you had "dim PcDate as Date"; if you still have that
    then your code is only working by coincidence. The assignment is formatting
    the internal system date as a string, then converting that back to a date
    format (which is numeric). When you assign it to the caption VB formats the
    date according to your local settings so the display will be different on
    different systems. You have two choices:
    a. Dim PcDate As String ' keep the formatting as specified
    b. Change the code to:
    Dim PcDate As Date
    PcDate=Date ' store dates in date format
    Label26.Caption=format$(PcDate,"DD-MM-YYYY") ' specify format on display

    If you always just want the current date you can lose the variable:
    Label26.Caption=format$(Date,"DD-MM-YYYY")

    I'd also suggest renaming 'Label26' to something meaningful like
    'lblDisplayDate' or whatever.




  6. #6
    Rick Rothstein Guest

    Re: Date in this format (DD-MM-YYYY).


    "Arthur Wood" <wooda@nospam.com> wrote in message
    news:3d539a9b$1@10.1.10.29...
    >
    > The Now() function is just that NOW - to the second. If all you want

    is the
    > Date, without worrying about what time it is, then use the Date()

    function.
    > The returned value can then be formatted as you want it, uing the

    Format$
    > function.
    >
    > Remembe, however, that Date values in VB are INTERNALLY held as

    NUMBERS (
    > a special type of DOUBLE), where the Integer part of the Number is the

    NUMBER
    > of DAYS since 12/31/1899,


    That should be 12/30/1899


    > and the fractional part of the Number is the fraction
    > of 1 24-hour day( as measured in milliseconds), so that 12:00 NOON

    would
    > be represented as 0.5


    Date variables only resolve to seconds.


    Rick



    >
    > Arthur Wood
    >
    >
    >
    > "AL KHALIFA" <salah@digitallinx.net> wrote:
    > >
    > >Sorry about this. Here is the complete post.
    > >
    > >Hi all,
    > >
    > >I need to capture the date from my PC.
    > >
    > >I used the following code:
    > >
    > >Dim PcDate As Date
    > >
    > >PcDate = Now()
    > >
    > >However, the variable PcDate returns the following:
    > >
    > >9/8/2002 10:10:00AM
    > >
    > >My question is:
    > >
    > >How to obtain the system date in the following format (DD-MM-YYYY)

    only?
    > >The time is not required in this application.
    > >
    > >
    > >Please help.
    > >
    > >Thanks in advance.
    > >
    > >AL KHALIFA
    > >
    > >
    > >

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center