format date

J

JT

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
 
R

Ray at

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
 
A

Aaron Bertrand - MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top