Wynalazkowo - eksperymenty małe i duże

Omnitracker

VisualBasic Script - formatowanie daty po swojemu

Jak szybko zmienić format daty w VisualBasic Scirpt na "yyyy-mm-dd":

 

Function GetFormattedDate(date1)

Dim strDate, strDay, strMonth, strYear

strDate = CDate(date1)

strDay = DatePart("d", strDate)

strMonth = DatePart("m", strDate)

strYear = DatePart("yyyy", strDate)

If strDay < 10 Then

strDay = "0" & strDay

End If

If strMonth < 10 Then

strMonth = "0" & strMonth

End If

GetFormattedDate = strYear & "/" & strMonth & "/" & strDay

End Function

 

Pozniej mozna w ladny sposob uzyc te date w zapytaniu  MS SQL Jet:

 

'find Total number of Clarifications

sql_str = "select col1,count(*) as Total from Table1,Table1_history where Table.Unique_Id=Table1_history.Object_ID  and Date>=#" + date_start_formatted + "# and Date<=#" + date_to_formatted + "# group by col1"

db.Execute(sql_str)