Date conversion

# Thread: Date conversion

1. Senior Member
Join Date
Dec 1969
Posts
745

## Date conversion

what is the best way to convert a date ie . 7/1/00 11:11:05 AM into a format such as 2000-07-01-11.11.05.000000 (ccyy-mm-dd-hh.nn.ss.kkkkkk)<BR><BR>Thanks,<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
379

## RE: Date conversion

Here you go<BR><BR>&#060;% Option Explicit<BR><BR> &#039Declare variables<BR> Dim dDateTimeStart, dDateTimeEnd<BR> <BR> &#039fill the variable<BR> dDateTimeStart = "7/1/00 11:11:05 AM "<BR> <BR> &#039deal with the year<BR> dDateTimeEnd = dDateTimeEnd & Year(dDateTimeStart) & "-"<BR> <BR> &#039deal with the month<BR> If Len(Month(dDateTimeStart)) = 1 Then<BR> dDateTimeEnd = dDateTimeEnd & "0" & Month(dDateTimeStart) & "-"<BR> Else<BR> dDateTimeEnd = dDateTimeEnd & Month(dDateTimeStart) & "-"<BR> End If<BR> <BR> &#039deal with the day<BR> If Len(Day(dDateTimeStart)) = 1 Then<BR> dDateTimeEnd = dDateTimeEnd & "0" & Day(dDateTimeStart) & "-"<BR> Else<BR> dDateTimeEnd = dDateTimeEnd & Day(dDateTimeStart) & "-"<BR> End If<BR> <BR> &#039deal with the hour<BR> If Len(Hour(dDateTimeStart)) = 1 Then<BR> dDateTimeEnd = dDateTimeEnd & "0" & Hour(dDateTimeStart) & "-"<BR> Else<BR> dDateTimeEnd = dDateTimeEnd & Hour(dDateTimeStart) & "-"<BR> End If <BR><BR> &#039deal with the Minute<BR> If Len(Minute(dDateTimeStart)) = 1 Then<BR> dDateTimeEnd = dDateTimeEnd & "0" & Minute(dDateTimeStart) & "-"<BR> Else<BR> dDateTimeEnd = dDateTimeEnd & Minute(dDateTimeStart) & "-"<BR> End If<BR> <BR> &#039deal with the month<BR> If Len(Second(dDateTimeStart)) = 1 Then<BR> dDateTimeEnd = dDateTimeEnd & "0" & Second(dDateTimeStart) & "-"<BR> Else<BR> dDateTimeEnd = dDateTimeEnd & Second(dDateTimeStart) & "-"<BR> End If<BR> <BR> &#039I don&#039t know what kkkkkk is but it would go here<BR> <BR> <BR> Response.Write dDateTimeEnd<BR> <BR>%&#062;<BR><BR>If this conversion needs to be done on a regular basis I would wrap it up in a function.<BR><BR>I hardcoded the dDateTimeStart, but you would obviously pass a value to that variable. You also wouldn&#039t need the response.write... that&#039s just there for testing<BR><BR>Hope this helps<BR><BR>bart

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•