I'm a little blockheaded right now…
我现在有点笨拙......
I have a date string in european format dd.mm.yyyy and need to transform it to mm.dd.yyyy with classic ASP. Any quick ideas?
我有一个欧洲格式的日期字符串dd.mm.yyyy,需要使用经典ASP将其转换为mm.dd.yyyy。任何快速的想法?
5 个解决方案
#1
5
If its always in that format you could use split
如果它始终采用该格式,则可以使用拆分
d = split(".","dd.mm.yyyy")
s = d(1) & "." & d(0) & "." & d(2)
this would allow for dates like 1.2.99 as well
这将允许1.2.99之类的日期
#2
4
Dim arrParts() As String
Dim theDate As Date
arrParts = Split(strOldFormat, ".")
theDate = DateTime.DateSerial(parts(2), parts(1), parts(0))
strNewFormat = Format(theDate, "mm.dd.yyyy")
#3
2
OK, I just found a solution myself:
好的,我刚刚找到了解决方案:
payment_date = MID(payment_date,4,3) & LEFT(payment_date,3) & MID(payment_date,7)
#4
2
This is a way to do it with built in sanity check for dates:
这是通过内置的健全性检查日期来实现的:
Dim OldString, NewString
OldString = "31.12.2008"
Dim myRegExp
Set myRegExp = New RegExp
myRegExp.Global = True
myRegExp.Pattern = "(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.]((19|20)[0-9]{2})"
If myRegExp.Test Then
NewString = myRegExp.Replace(OldString, "$2.$1.$3")
Else
' A date of for instance 32 December would end up here
NewString = "Invalid date"
End If
#5
0
I have my own date manipulation functions which I use in all my apps, but it was originally based on this sample:
我有自己的日期操作功能,我在我的所有应用程序中使用,但它最初基于此示例:
#1
5
If its always in that format you could use split
如果它始终采用该格式,则可以使用拆分
d = split(".","dd.mm.yyyy")
s = d(1) & "." & d(0) & "." & d(2)
this would allow for dates like 1.2.99 as well
这将允许1.2.99之类的日期
#2
4
Dim arrParts() As String
Dim theDate As Date
arrParts = Split(strOldFormat, ".")
theDate = DateTime.DateSerial(parts(2), parts(1), parts(0))
strNewFormat = Format(theDate, "mm.dd.yyyy")
#3
2
OK, I just found a solution myself:
好的,我刚刚找到了解决方案:
payment_date = MID(payment_date,4,3) & LEFT(payment_date,3) & MID(payment_date,7)
#4
2
This is a way to do it with built in sanity check for dates:
这是通过内置的健全性检查日期来实现的:
Dim OldString, NewString
OldString = "31.12.2008"
Dim myRegExp
Set myRegExp = New RegExp
myRegExp.Global = True
myRegExp.Pattern = "(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.]((19|20)[0-9]{2})"
If myRegExp.Test Then
NewString = myRegExp.Replace(OldString, "$2.$1.$3")
Else
' A date of for instance 32 December would end up here
NewString = "Invalid date"
End If
#5
0
I have my own date manipulation functions which I use in all my apps, but it was originally based on this sample:
我有自己的日期操作功能,我在我的所有应用程序中使用,但它最初基于此示例: