J
Jan Kronsell
I have a function like this
Function CprTilDato(cpr As String) As Date
a lot of code here.....
CprTilDato = Left(cpr, 2) & "-" & Mid(cpr, 3, 2) & "-" & bytCent &
bytCprYear
End Function
where
bytCent = 20
bytCprYear = 10
Left(Cpr, 2) = 20
Mid(cpr, 3,2) = 01
I want it to return a date in format dd-mm-yyyy but it returns the value,
like instead of returning 20-01-2010 today, it returns 40198.
If I change declaration of the function to
Function CprTilDato(cpr As String) As String
it returns the date allright, but as a string as it should, and then I can't
use the result for calculations.
I can format the cell afterwards of cause, but is'nt it possible to have the
function returning a formated date value?
I tried stuff like
CprTilDato = Format(CprTilDato, "dd-mm-yyyy")
CprTilDato = Format(CDate(CprTilDato), "dd-mm-yyyy")
CprTilDato = CDate(CprTilDato)
CprTilDato = DateSerial(bytCent & bytCprYear, Mid(cpr, 3, 2),
Left(cpr, 2))
but so far, no good.
Jan
Function CprTilDato(cpr As String) As Date
a lot of code here.....
CprTilDato = Left(cpr, 2) & "-" & Mid(cpr, 3, 2) & "-" & bytCent &
bytCprYear
End Function
where
bytCent = 20
bytCprYear = 10
Left(Cpr, 2) = 20
Mid(cpr, 3,2) = 01
I want it to return a date in format dd-mm-yyyy but it returns the value,
like instead of returning 20-01-2010 today, it returns 40198.
If I change declaration of the function to
Function CprTilDato(cpr As String) As String
it returns the date allright, but as a string as it should, and then I can't
use the result for calculations.
I can format the cell afterwards of cause, but is'nt it possible to have the
function returning a formated date value?
I tried stuff like
CprTilDato = Format(CprTilDato, "dd-mm-yyyy")
CprTilDato = Format(CDate(CprTilDato), "dd-mm-yyyy")
CprTilDato = CDate(CprTilDato)
CprTilDato = DateSerial(bytCent & bytCprYear, Mid(cpr, 3, 2),
Left(cpr, 2))
but so far, no good.
Jan