Jeg har et lille spm. ang datoformater. Jeg har f.eks. følgende 25-11-2005 som jeg gerne vil have konverteret til formatet yyyymmdd. Hvordan gør jeg det?? Og for den sags skyld også tilbage igen.
Function ConvertToSqlDate(dato) dim SQLYear,SQLMonth,SQLDay SQLYear = Year(dato) SQLMonth = Month(dato) SQLDay = Day(dato) if SQLDay<10 then SQLDay = 0&SQLDay end if if SQLMonth<10 then SQLMonth = 0&SQLMonth end if if ConstDateFormat = 1 then ConvertToSqlDate = SQLMonth&"-"&SQLDay&"-"&SQLYear elseif ConstDateFormat = 2 then ConvertToSqlDate = SQLYear&SQLMonth&SQLDay else ConvertToSqlDate = SQLYear&SQLMonth&SQLDay end if End Function
Function ConvertToSqlDate(dato) dim SQLYear,SQLMonth,SQLDay SQLYear = Year(dato) SQLMonth = Month(dato) SQLDay = Day(dato) if SQLDay<10 then SQLDay = 0&SQLDay end if if SQLMonth<10 then SQLMonth = 0&SQLMonth end if ConvertToSqlDate = SQLYear&SQLMonth&SQLDay End Function
Den før har indbygget funktionalitet til at skifte mellem Access og MS-SQL formatet.
<% Function convertDate(dato) convertDate = Year(dato) If Len(Month(dato)) = 1 Then convertDate = convertDate & "0" End If convertDate = convertDate & Month(dato) If Len(Day(dato)) = 1 Then convertDate = convertDate & "0" End If convertDate = convertDate & Day(dato) End Function
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.