We help IT Professionals succeed at work.

How do I display leading zero in ASP?

980 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

Comment
Watch Question

Saqib KhanSenior Developer

Commented:
What is The DataType in Database for Birthday?

Try following...

 <%=cStr(rs("birthday"))%>
Try this
<%=Format(rs("birthday"), "mm/dd/yyyy")%>

Author

Commented:
Thank you adlikhan, but it didn't work. sorry.

Data Type is DateTime.
Help me~ ^^
Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer / Applications Consultant
CERTIFIED EXPERT

Commented:
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%>
Software Tead Lead / Business Analyst / System Analyst / Data Engineer / Applications Consultant
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Did you try this?
<%=Format(rs("birthday"), "mm/dd/yyyy")%>
Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer / Applications Consultant
CERTIFIED EXPERT

Commented:
@asvforce,

Format function is not available in ASP (vbscript)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.