473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to get date time to display like 01/01/2005 16:14:10?



How to get date time to display like 01/01/2005 16:14:10?

Here's something that I found works against an Oracle database.
However, I'm not getting the same results against a SQL 2000 database.
Can anyone point out the correction needed? With the following, the
time displays correctly, but no date at all.

<%d=formatdatetime(rs2("Begin_Time"), 2)
if mid(d,2,1)="/" then d="0" & d
if mid(d,5,1)="/" then d=left(d,3) & "0" & mid(d,4)
Response.Write (d) & "&nbsp;"
Response.Write formatdatetime(rs2("Begin_Time"), 4)
if second(rs2("Begin_Time")) < 10 then
Response.Write ":0" & second(rs2("Begin_Time"))
else
Response.Write ":" & second(rs2("Begin_Time"))
end if%>

TIA
Jul 22 '05 #1
7 1396
ziggs wrote:
How to get date time to display like 01/01/2005 16:14:10?
Construct a better question. Is your date portion mm/dd/yyyy or dd/mm/yyyy ?
Here's something that I found works against an Oracle database.
However, I'm not getting the same results against a SQL 2000 database.
Can anyone point out the correction needed? With the following, the
time displays correctly, but no date at all.

<%d=formatdatetime(rs2("Begin_Time"), 2)
if mid(d,2,1)="/" then d="0" & d
if mid(d,5,1)="/" then d=left(d,3) & "0" & mid(d,4)
Response.Write (d) & "&nbsp;"
Response.Write formatdatetime(rs2("Begin_Time"), 4)
if second(rs2("Begin_Time")) < 10 then
Response.Write ":0" & second(rs2("Begin_Time"))
else
Response.Write ":" & second(rs2("Begin_Time"))
end if%>


Among other things, you can get SQL Server to formet your dates:
http://msdn.microsoft.com/library/en...ca-co_2f3o.asp

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #2
ziggs wrote:
How to get date time to display like 01/01/2005 16:14:10?

http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion
http://www.aspfaq.com/show.asp?id=2023 date delimiters

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #3
some tips
http://www.powerasp.com/content/new/...e-and-time.asp

"ziggs" <zi***@hotmail.com> wrote in message
news:5p********************************@4ax.com...


How to get date time to display like 01/01/2005 16:14:10?

Here's something that I found works against an Oracle database.
However, I'm not getting the same results against a SQL 2000 database.
Can anyone point out the correction needed? With the following, the
time displays correctly, but no date at all.

<%d=formatdatetime(rs2("Begin_Time"), 2)
if mid(d,2,1)="/" then d="0" & d
if mid(d,5,1)="/" then d=left(d,3) & "0" & mid(d,4)
Response.Write (d) & "&nbsp;"
Response.Write formatdatetime(rs2("Begin_Time"), 4)
if second(rs2("Begin_Time")) < 10 then
Response.Write ":0" & second(rs2("Begin_Time"))
else
Response.Write ":" & second(rs2("Begin_Time"))
end if%>

TIA

Jul 22 '05 #4
The format that I'm looking for is mm/dd/yyyy for the 01/01/2005
example. I read the other two posts and their links. However, I'm
just more confused now.

On Tue, 21 Jun 2005 08:02:21 -0500, "Dave Anderson"
<GT**********@spammotel.com> wrote:
ziggs wrote:
How to get date time to display like 01/01/2005 16:14:10?


Construct a better question. Is your date portion mm/dd/yyyy or dd/mm/yyyy ?
Here's something that I found works against an Oracle database.
However, I'm not getting the same results against a SQL 2000 database.
Can anyone point out the correction needed? With the following, the
time displays correctly, but no date at all.

<%d=formatdatetime(rs2("Begin_Time"), 2)
if mid(d,2,1)="/" then d="0" & d
if mid(d,5,1)="/" then d=left(d,3) & "0" & mid(d,4)
Response.Write (d) & "&nbsp;"
Response.Write formatdatetime(rs2("Begin_Time"), 4)
if second(rs2("Begin_Time")) < 10 then
Response.Write ":0" & second(rs2("Begin_Time"))
else
Response.Write ":" & second(rs2("Begin_Time"))
end if%>


Among other things, you can get SQL Server to formet your dates:
http://msdn.microsoft.com/library/en...ca-co_2f3o.asp


Jul 22 '05 #5
"ziggs" <zi***@hotmail.com> wrote in message
news:f0********************************@4ax.com...
The format that I'm looking for is mm/dd/yyyy for the 01/01/2005
example. I read the other two posts and their links. However, I'm
just more confused now.


[snip]

Will this help? Watch for word-wrap.

Response.Write MyFormatDateTime(rs2("Begin_Time"))

Function MyFormatDateTime(when)
Dim strMDY
strMDY = Right(100+DatePart("m",when),2) & "/"
strMDY = strMDY & Right(100+DatePart("d",when),2) & "/"
strMDY = strMDY & DatePart("yyyy",when)
Dim strHMS
strHMS = Right(100+DatePart("h",when),2) & ":"
strHMS = strHMS & Right(100+DatePart("n",when),2) & ":"
strHMS = strHMS & Right(100+DatePart("s",when),2)
MyFormatDateTime = strMDY & " " & strHMS
End Function
Jul 22 '05 #6
It didn't work. It said that the "m" in

strMDY = Right(100+DatePart("m",when),2*) & "/"

was an invalid character.

Jul 22 '05 #7
<zn****@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
It didn't work. It said that the "m" in

strMDY = Right(100+DatePart("m",when),2*) & "/"

was an invalid character.
Are you sure?

Retrieving Specific Portions of a Date and Time Value
http://www.microsoft.com/technet/scr..._vbs_ufbq.mspx
I suspect that the value of "when" is not a valid date.

Try this:

Response.Write "<br>when = " & when
Response.Write "<br>Month = " & DatePart("m",when)

at the top of the Function and see what you get.

Post the results if there' still a problem.
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dave | last post by:
Hi I am hoping someone might be able to help me out with this. I am writing a helpdesk system which records agents logging in and out of the system. I need to write a stored procedure which...
2
by: gardnern | last post by:
Is it possible to get the expiration date/time of a cookie? I need to limit someone to visiting a couple of pages for 45 minutes max and would like to show them how much time they have left. I dont...
3
by: andrew | last post by:
Hi: I am already using TreeMap to massage records in my export file such that each record has a unique key combination ( LastName + FirstName + Member Key) . Thus I am sorting the records by...
6
by: Wire | last post by:
Hello I want to sum these records on month(datum) and device and get then get the min and max values and the associated low high date/times this does not work select month(datum) as...
0
by: voipcanada | last post by:
NEED CONVERSION FOR "14:10:01.000 GMT Sat Oct 22 2005" AS "2005-10-22 14:10:01" thanks
0
by: Ed Bick | last post by:
Well, I read today about how I could set the dropdown value to False to change the control from presenting a Calendar to cycling through the times. Before getting that, I developed a custom Time...
7
by: mr.nimz | last post by:
hello, this is antenio. recently i've come to a problem. i got a way through it, somehow, still it left me in a curious state, so i'm posting it here, if i can get an answer from some techy, ...
8
by: ghjk | last post by:
In my php application I got the date and time as two separate values.(User entered value) ex:date =06-07-2008 time =16:10 I want to combine those two values and convert the date format like the...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.