473,498 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date with zeros

Aside from rolling my own solution (obviously not very difficult), is there
any way to cause a date such as 6/5/2004 to show up as 06/05/2004? Just
didn't know if there was an ASP function to do this or not.

Thanks,
James
Jul 19 '05 #1
5 1316
James Baker wrote on 16 jun 2004 in
microsoft.public.inetserver.asp.general:
Aside from rolling my own solution (obviously not very difficult), is
there any way to cause a date such as 6/5/2004 to show up as
06/05/2004? Just didn't know if there was an ASP function to do this
or not.


No, there is no ASP function, as ASP is not a language but a platform
accommodating different languages serverside.

6/5/2004 could mean two different dates, btw.

==================================

//Javascript solution:

var d = "6/5/2004"

function two(x){
return (x<10)?"0"+x:""+x
}

d = d.split("/")

d[0] = two(d[0])
d[1] = two(d[1])

d = d.join("/")

====================================

'' vbscript solution

d = "6/5/2004"

function two(x)
two = right("0" & x, 2)
end function

d2 = split(d,"/")
d2(0) = two(d2(0))
d2(1) = two(d2(1))

d = join(d2,"/")
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2
Semantics, lol. Yeah, I know the solution is a cakewalk but I figured if
there was a function, why not use it. Thanks none-the-less.

James
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
James Baker wrote on 16 jun 2004 in
microsoft.public.inetserver.asp.general:
Aside from rolling my own solution (obviously not very difficult), is
there any way to cause a date such as 6/5/2004 to show up as
06/05/2004? Just didn't know if there was an ASP function to do this
or not.


No, there is no ASP function, as ASP is not a language but a platform
accommodating different languages serverside.

6/5/2004 could mean two different dates, btw.

==================================

//Javascript solution:

var d = "6/5/2004"

function two(x){
return (x<10)?"0"+x:""+x
}

d = d.split("/")

d[0] = two(d[0])
d[1] = two(d[1])

d = d.join("/")

====================================

'' vbscript solution

d = "6/5/2004"

function two(x)
two = right("0" & x, 2)
end function

d2 = split(d,"/")
d2(0) = two(d2(0))
d2(1) = two(d2(1))

d = join(d2,"/")
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #3
To make a variable be in the format of mm/dd/yyyy (and the final line of
code can be modifed for other date formats), perhaps try something like
the following which you might even make into a function:

varFld = CDate(MyVariable)

intMonth = Month(varFld)
intDay = Day(varFld)
intYr = Year(varFld)

If intMonth < 10 Then
strMonth = "0" & CStr(intMonth)
Else
strMonth = CStr(intMonth)
End If

If intDay < 10 Then
strDay = "0" & CStr(intDay)
Else
strDay = CStr(intDay)
End If

strYr = Right(CStr(intYr), 4) ' And change the 4 to 2 for 2 year dates.

varFld = CStr(strMonth & "/" & strDay & "/" & strYr)

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
Function FormatDate(dtm1)
FormatDate = "NAD" ' Not A Date
If IsDAte(dtm1) Then
FormatDate = Right("00" & Month(dtm1),2) & "/" & Right("00" & Day(dtm1),2) & "/" &
Year(dtm1)
End If
End Function

'dlbjr

'Unambit from meager knowledge of inane others,engender uncharted sagacity.
Jul 19 '05 #5
"dlbjr" <oo**@iforgot.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
: Function FormatDate(dtm1)
: FormatDate = "NAD" ' Not A Date
: If IsDAte(dtm1) Then
: FormatDate = Right("00" & Month(dtm1),2) & "/" & Right("00" &
Day(dtm1),2) & "/" &
: Year(dtm1)
: End If
: End Function

you only need one zero there buddy...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #6

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

Similar topics

16
13099
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two...
6
2200
by: Piotr Pietrowski | last post by:
Hello everybody, I have a *big* problem. I thought its not that big problem for you professionals... Anyway, I have a begin date which has 3 dropdown boxes (day/Month/Year). The same for the...
23
4079
by: middletree | last post by:
I have a field that is stored in SQL Server in date/time format. On one page, I only need the date to display. I am able to do this by saying: DateValue(strLastModified) However, this returns...
15
3864
by: Paul J. Ettl | last post by:
Two questions: I use var date1 = new Date(); to get todays date. But how can I get yesterdays date? Furthermore I use
8
25355
by: dlx_son | last post by:
Here is the code so far <form name="thisform"> <h3>Enter time to add to or subtract from:</h3> (If not entered, current time will be used)<br> Day: <input name="d1" alt="Day of month"...
11
5872
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
2
11888
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
11
21054
by: walterbyrd | last post by:
My MySQL table has a field that is set as type "date." I need to get today's date, and insert it into that field. The default for that MySQL field is 2006-00-00. I know about the date()...
5
3465
by: GarryJones | last post by:
I have code numbers in 2 fields from a table which correspond to month and date. (Month, Code number) Field name = ml_mna 1 2 3 etc up to 12 (Data is entered without a leading zero)
4
4634
xstatic
by: xstatic | last post by:
After searching through the hundreds of links about "Javascript Date Formatting", all I am finding is how to format dates that gives a "current date" result. Here is what I need... I have a...
0
7125
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
7002
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
7165
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
5462
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,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.