[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I display leading zero in ASP?

Posted on 2007-10-02
7
Medium Priority
?
940 Views
Last Modified: 2012-05-05
Hello Experts,

I have a data called birthday. When I check my db, it's in 01/01/2007 format, but when I use asp: <%=rs("birthday")%>  to bring  that data, it displays 1/1/2007.

What do I have to do?
Thank you

0
Comment
Question by:erin027
7 Comments
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 20004171
What is The DataType in Database for Birthday?

Try following...

 <%=cStr(rs("birthday"))%>
0
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20004208
Try this
<%=Format(rs("birthday"), "mm/dd/yyyy")%>
0
 

Author Comment

by:erin027
ID: 20004216
Thank you adlikhan, but it didn't work. sorry.

Data Type is DateTime.
Help me~ ^^
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 54

Expert Comment

by:Ryan Chong
ID: 20004236
try:

if you want format mm/dd/yyyy:

newDateStr = right("0" & month(v), 2) & "/" & right("0" & day(v), 2) & "/" & right("00" & year(rs("birthday")), 4)

or:


if you want format dd/mm/yyyy:

newDateStr = right("0" & day(v), 2) & "/" & right("0" & month(v), 2) & "/" & right("00" & year(rs("birthday")), 4)

then <%=newDateStr%>
0
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 20004238
sorry, try this instead:

if you want format mm/dd/yyyy:

newDateStr = right("0" & month(rs("birthday")), 2) & "/" & right("0" & day(rs("birthday")), 2) & "/" & right("00" & year(rs("birthday")), 4)

or:

if you want format dd/mm/yyyy:

newDateStr = right("0" & day(rs("birthday")), 2) & "/" & right("0" & month(rs("birthday")), 2) & "/" & right("00" & year(rs("birthday")), 4)

then <%=newDateStr%>
0
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20004314
Did you try this?
<%=Format(rs("birthday"), "mm/dd/yyyy")%>
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 20004364
@asvforce,

Format function is not available in ASP (vbscript)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question