vb YYYY-MM-DD Date Format

Private Function ConvertDate(dDate)
	'converts date to YYYY-MM-DD format
	Dim dReturn
	Dim dYear
	Dim dMonth
	Dim dDay

	dYear = DatePart("yyyy", dDate)
	dMonth = DatePart("m", dDate)
	dDay = DatePart("d", dDate)

	'ensure month/day is in MM/DD format
	If dMonth < 10 Then dMonth = "0" & dMonth
	If dDay < 10 Then dDay = "0" & dDay

	dReturn = dYear & "-" & dMonth & "-" & dDay
	
	ConvertDate = dReturn
End Function
Formats a date to YYYY-MM-DD.

Updated: Saturday 9th October 2010, 01:42pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.