Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > format date

Reply
Thread Tools

format date

 
 
JT
Guest
Posts: n/a
 
      10-06-2003
i have a date stored in my db in this format: 2005-03-15 00:00:00.000

however, i want to display this date on my .asp page in this format: 03/05

is there a quick function to do this?

tmia

jt


 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      10-06-2003
sDate = "2005-03-15 00:00:00.000"
sDate = Split(sDate, " ")(0)
sDate = Right("0" & Month(sDate), 2) & "/" & Right("0" & Day(sDate), 2)
Response.write sDAte

Ray at work


"JT" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> i have a date stored in my db in this format: 2005-03-15 00:00:00.000
>
> however, i want to display this date on my .asp page in this format:

03/05
>
> is there a quick function to do this?
>
> tmia
>
> jt
>
>



 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      10-06-2003
> i have a date stored in my db in this format: 2005-03-15 00:00:00.000

Stored in what db, SQL Server? This is not how it's stored. Internally,
it's stored as two integer values (one for the date, and one for the time).
What you are seeing is some client tool's representation format (Enterprise
Manager, perhaps?).

To get it out the way you like, you can handle the formatting on the client
as Ray suggests, or you can handle it in the database as follows:

SELECT RIGHT('0'+RTRIM(MONTH(someColumn)), 2)
+ '/' + RIGHT('0'+RTRIM(YEAR(someColumn)), 2)
FROM someTable


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C Programming 3 11-08-2003 09:07 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments