Hi
Dim d As New Date
dim today as string = d.SQLDate
MsgBox(today)
Returns date string as “2013-08-2” however I am need the string to be “130802”
Just looking for the best way to do do this…
Thanks for any help with this
Hi
Dim d As New Date
dim today as string = d.SQLDate
MsgBox(today)
Returns date string as “2013-08-2” however I am need the string to be “130802”
Just looking for the best way to do do this…
Thanks for any help with this
Where exactly are you seeing this 2013-08-2 with the missing 0 before the two? That would be a bad bug.
And this is a perfect SQL Date. If you need a different one, please write your own function.
Function YYMMDD(d As Date) As String
// Receive Date, return String “YYMMDD”
Return Format((d.Year mod 100)10000+d.Month100+d.Day,“000000”)
End Function
better use Str() instead of Format() here.
Format is localized.
Ok, but does not affects the function. Just math with no localization effects.
Function yymmdd(extends d as Date) As String
Return d.SQLDate.ReplaceAll("-","").Mid(3)
End Function
and it’s counter part
Sub yymmdd(extends d as date,assigns s as String)
if s.Len=6 then
dim sd as String=“20”+s.left(2)+"-"+s.Mid(3,2)+"-"+s.Right(2)
d.SQLDate=sd
end if
End Sub
Not sure why you’d want to omit the century though. You’re going to have a year 2100 problem. (Yes, I fully expect to be around to say, “I told you so.”)