Ask a Question related to ASP Database, Design and Development.
-
Bob The ASP Builder #1
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
-
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 >... -
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... -
Convert date/time to date in SQL Server 2000 statement
Can this be done? tia -
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... -
*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... -
Aaron Bertrand [MVP] #2
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
-
Roland Hall #3
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
-
Bob The ASP Builder #4
Re: Presenting Date & Time Info
On Fri, 9 Apr 2004 11:11:42 -0500, "Roland Hall" <nobody@nowhere>
wrote:
THANK YOU - but this was a lot easier - dont you think?>"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...
Present date:
<%= FormatDateTime(RS("Indate"),vbShortDate)%>
Present time:
<%= FormatDateTime(RS("Indate"),vbShortTime)%>
Bob
Bob The ASP Builder Guest
-
Roland Hall #5
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



Reply With Quote

