View Full Version : How to split the date without "/" in asp?
08-06-2004, 03:48 AM
How to split the date "1/8/2004" in to 01082004?
If posible make it in the single line?
eg: < % Split(strDate, "/") ... ???
PS: i want to add the 0 ,if there are 1 digit of value. -- this is the problem i face on.
08-06-2004, 04:27 AM
I already solve the problem. TQ
08-06-2004, 04:57 AM
Well, glad I could help.
Now there is a little issue of my fee?
$10,000 in small, unmarked bills.
08-07-2004, 04:47 AM
How did you solved it, we might find a similar situation some time... ;)
08-07-2004, 05:45 AM
After I looked at this post, I tried to do it. I tried to use programed in functions, and the best I could do is:
Response.Write Day(Date) & Month(Date) & Year(Date)
This doesn't solve the problem, so I thought making a function would help.
This would work, but is more than one line, so it's what I was hoping:
If Len(strVar) = 1 Then
LeadingZero = "0" & strVar
LeadingZero = strVar
Response.Write LeadingZero(Day(Date)) & LeadingZero(Month(Date)) & Year(Date)
I looked up the format function, but I couldn't find the type of function I was looking for. I want to use something like DateFunction(Date(), "ddmmyyyy").
d - day.
dd - day with leading zero if applicable.
m - month.
mm - month with leading zero if applicable.
yyyy - year.
yy - last two digits of the year.
Also with time.
s - seconds.
ss - seconds with leading zero if applicable.
n - minute
nn - minute with leading zero if applicable.
h - hour
hh - hour with leading zero if applicable.
hhh - hour in military time
And of course any added characters would not be effected, so adding a slash would still be there.
But I can't find a function like this already built into asp.
I know there is function in vb that already has keys and already adds a leading zero:
MsgBox Format(Date, "ddmmyyyy")
I want to find/make the Format function in vb and add it to my webserver, or my included function.asp page.
:eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek:
I found this link, which gives me a dll I can register onto my server so it will be allow me to use the format function from vb in ASP.
I also found this link, which shows you the keys for the format function. Something I was looking for already built into ASP.
08-10-2004, 02:52 AM
Actually my solution is what Morgoth mentioned!!! :o)
08-10-2004, 04:14 AM
And for a possible non-DLL-required way to go:
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)
strMonth = CStr(intMonth)
If intDay < 10 Then
strDay = "0" & CStr(intDay)
strDay = CStr(intDay)
strYr = Right(CStr(intYr), 4) ' And change the 4 to 2 for 2 year dates.
varFld = CStr(strMonth & "/" & strDay & "/" & strYr)
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.