Presenting Date & Time Info

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Presenting Date & Time Info

    In an Access 2000 Database I automatically in a table store the date
    and time -information when a row has been created.The info is stored
    in fields in a column named "Indate"

    I have set the Datatype to "Date/time" and the standarvalue to "Now()"
    - furthermore I have set the Format to "Short Date"

    All of this works perfectly and the visible reading of the
    "Indate"-field in a row created today is 2004-04-08

    Now my question:

    When presenting data from this row using a statement:
    SQL = "SELECT * FROM MyTable"

    leaving a lot of code out.......

    <% = RS("Indate") %>

    What gets presented is for example "2004-04-08 05:03:36"

    This must mean that the table/column/field actually stores more than I
    can see visually watching the data when opening the database

    So I suppose there is a way of controlling how it is presented!!?? Is
    there??

    I would like to be able to show this content as "2004-04-08" or in
    another case as "05:03"

    How do I do that?
    Bob The ASP Builder Guest

  2. Similar Questions and Discussions

    1. CFMX7.0.1 Administrator date time issue showing 13hrsbehind server time
      I am running a W2k SP4 box that has been upgraded from CFMX6 to CFMX7.0.1. The CFMX7.0.1 server is showing the date on the Server Settings >...
    2. SQL: can a date ONLY contain month/year info?
      When using a SQL datetime field, is there a way to store ONLY the month and year? I have a situation where I need to store both month/year and...
    3. Time/Date format and changing time to GMT
      Hi All, Sorry if this is the wrong newsgroup to post into, on this topic, if so, please point me in the right direction..... Currently working...
    4. *very* strange date issue (more info)
      Have you check the regional settings and date and time on the server compared to your dev machine? I came across a similar issue with a VB 6 app...
  3. #2

    Default Re: Presenting Date & Time Info

    Look at the formatdatetime() function in the VBScript documentation. Or,
    search aspfaq.com for yyyymmdd ... you should find plenty of date formatting
    articles.



    "Bob The ASP Builder" <boj@isplanket.com> wrote in message
    news:rbg9705tqc7a495i4i6pr15c4tdi5o5iko@4ax.com...
    > In an Access 2000 Database I automatically in a table store the date
    > and time -information when a row has been created.The info is stored
    > in fields in a column named "Indate"
    >
    > I have set the Datatype to "Date/time" and the standarvalue to "Now()"
    > - furthermore I have set the Format to "Short Date"
    >
    > All of this works perfectly and the visible reading of the
    > "Indate"-field in a row created today is 2004-04-08
    >
    > Now my question:
    >
    > When presenting data from this row using a statement:
    > SQL = "SELECT * FROM MyTable"
    >
    > leaving a lot of code out.......
    >
    > <% = RS("Indate") %>
    >
    > What gets presented is for example "2004-04-08 05:03:36"
    >
    > This must mean that the table/column/field actually stores more than I
    > can see visually watching the data when opening the database
    >
    > So I suppose there is a way of controlling how it is presented!!?? Is
    > there??
    >
    > I would like to be able to show this content as "2004-04-08" or in
    > another case as "05:03"
    >
    > How do I do that?

    Aaron Bertrand [MVP] Guest

  4. #3

    Default Re: Presenting Date & Time Info

    "Bob The ASP Builder" wrote in message
    news:rbg9705tqc7a495i4i6pr15c4tdi5o5iko@4ax.com...
    : In an Access 2000 Database I automatically in a table store the date
    : and time -information when a row has been created.The info is stored
    : in fields in a column named "Indate"
    :
    : I have set the Datatype to "Date/time" and the standarvalue to "Now()"
    : - furthermore I have set the Format to "Short Date"
    :
    : All of this works perfectly and the visible reading of the
    : "Indate"-field in a row created today is 2004-04-08
    :
    : Now my question:
    :
    : When presenting data from this row using a statement:
    : SQL = "SELECT * FROM MyTable"
    :
    : leaving a lot of code out.......
    :
    : <% = RS("Indate") %>
    :
    : What gets presented is for example "2004-04-08 05:03:36"
    :
    : This must mean that the table/column/field actually stores more than I
    : can see visually watching the data when opening the database
    :
    : So I suppose there is a way of controlling how it is presented!!?? Is
    : there??
    :
    : I would like to be able to show this content as "2004-04-08" or in
    : another case as "05:03"

    dim arrDate, myDate, aDate, aTime
    myDate = "2004-04-08 05:03:36"
    arrDate = split(myDate," ")
    aDate = join(split(arrDate(0)))
    aTime = left(join(split(arrDate(1))),5)

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Documentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]


    Roland Hall Guest

  5. #4

    Default Re: Presenting Date & Time Info

    On Fri, 9 Apr 2004 11:11:42 -0500, "Roland Hall" <nobody@nowhere>
    wrote:
    >"Bob The ASP Builder" wrote in message
    >news:rbg9705tqc7a495i4i6pr15c4tdi5o5iko@4ax.com.. .
    >: In an Access 2000 Database I automatically in a table store the date
    >: and time -information when a row has been created.The info is stored
    >: in fields in a column named "Indate"
    >:
    >: I have set the Datatype to "Date/time" and the standarvalue to "Now()"
    >: - furthermore I have set the Format to "Short Date"
    >:
    >: All of this works perfectly and the visible reading of the
    >: "Indate"-field in a row created today is 2004-04-08
    >:
    >: Now my question:
    >:
    >: When presenting data from this row using a statement:
    >: SQL = "SELECT * FROM MyTable"
    >:
    >: leaving a lot of code out.......
    >:
    >: <% = RS("Indate") %>
    >:
    >: What gets presented is for example "2004-04-08 05:03:36"
    >:
    >: This must mean that the table/column/field actually stores more than I
    >: can see visually watching the data when opening the database
    >:
    >: So I suppose there is a way of controlling how it is presented!!?? Is
    >: there??
    >:
    >: I would like to be able to show this content as "2004-04-08" or in
    >: another case as "05:03"
    >
    >dim arrDate, myDate, aDate, aTime
    >myDate = "2004-04-08 05:03:36"
    >arrDate = split(myDate," ")
    >aDate = join(split(arrDate(0)))
    >aTime = left(join(split(arrDate(1))),5)
    >
    >HTH...
    THANK YOU - but this was a lot easier - dont you think?

    Present date:
    <%= FormatDateTime(RS("Indate"),vbShortDate)%>
    Present time:
    <%= FormatDateTime(RS("Indate"),vbShortTime)%>

    Bob
    Bob The ASP Builder Guest

  6. #5

    Default Re: Presenting Date & Time Info

    "Bob The ASP Builder" wrote in message
    news:iaoe70ln5lrnq8se49me09htajcempv5fn@4ax.com...
    : On Fri, 9 Apr 2004 11:11:42 -0500, "Roland Hall" <nobody@nowhere>
    : wrote:
    :
    : >"Bob The ASP Builder" wrote in message
    : >news:rbg9705tqc7a495i4i6pr15c4tdi5o5iko@4ax.com.. .
    : >: In an Access 2000 Database I automatically in a table store the date
    : >: and time -information when a row has been created.The info is stored
    : >: in fields in a column named "Indate"
    : >:
    : >: I have set the Datatype to "Date/time" and the standarvalue to "Now()"
    : >: - furthermore I have set the Format to "Short Date"
    : >:
    : >: All of this works perfectly and the visible reading of the
    : >: "Indate"-field in a row created today is 2004-04-08
    : >:
    : >: Now my question:
    : >:
    : >: When presenting data from this row using a statement:
    : >: SQL = "SELECT * FROM MyTable"
    : >:
    : >: leaving a lot of code out.......
    : >:
    : >: <% = RS("Indate") %>
    : >:
    : >: What gets presented is for example "2004-04-08 05:03:36"
    : >:
    : >: This must mean that the table/column/field actually stores more than I
    : >: can see visually watching the data when opening the database
    : >:
    : >: So I suppose there is a way of controlling how it is presented!!?? Is
    : >: there??
    : >:
    : >: I would like to be able to show this content as "2004-04-08" or in
    : >: another case as "05:03"
    : >
    : >dim arrDate, myDate, aDate, aTime
    : >myDate = "2004-04-08 05:03:36"
    : >arrDate = split(myDate," ")
    : >aDate = join(split(arrDate(0)))
    : >aTime = left(join(split(arrDate(1))),5)
    : >
    : >HTH...
    :
    : THANK YOU - but this was a lot easier - dont you think?
    :
    : Present date:
    : <%= FormatDateTime(RS("Indate"),vbShortDate)%>
    : Present time:
    : <%= FormatDateTime(RS("Indate"),vbShortTime)%>

    Easier yes, but this is not what you requested.
    You requested yyyy-mm-dd. vbShortDate returns the date in the format set in
    your regional settings.
    Also, vbShortTime uses the 24 hour format, so 5pm will be returned as 17.
    But, since you're providing the values and not actually getting the current
    time to display, the time should be displayed however you specify.

    Yours method displays first.
    [url]http://kiddanger.com/lab/sdatetime.asp[/url]

    <%@ Language=VBScript %>
    <%
    Option Explicit
    Response.Buffer = True

    sub lPrt(str)
    Response.Write(str & "<br />" & vbCrLf)
    end sub
    dim indate
    indate = "2004-04-08 05:03:36"
    lPrt(FormatDateTime(Indate,vbShortDate))
    lPrt(FormatDateTime(Indate,vbShortTime))

    dim arrDate, myDate, aDate, aTime
    myDate = "2004-04-08 05:03:36"
    arrDate = split(myDate," ")
    aDate = join(split(arrDate(0)))
    aTime = left(join(split(arrDate(1))),5)
    lPrt("-----")
    lPrt(aDate)
    lPrt(aTime)
    %>

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Documentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]


    Roland Hall Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139