Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

yyyymmddhhmm date format

yyyymmddhhmm date format

yyyymmddhhmm date format

I need to find a way to convert the current date/time (i.e. Now()) into this "yyyymmddhhmm" format. Can anyone tell me how to do this? Can this be done?

RE: yyyymmddhhmm date format

Here's what I use:


currenttime = ConvWMIDateTime(objOS.LocalDateTime, "ISO8601")
Wscript.Echo "The time is " & currenttime

Function ConvWMIDateTime(sDMTFformat, iNamedFormat)

   Dim sYear, sMonth, sDay, sHour, sMinutes, sSeconds
   sYear = mid(sDMTFformat, 1, 4)
   sMonth = mid(sDMTFformat, 5, 2)
   sDay = mid(sDMTFformat, 7, 2)
   sHour = mid(sDMTFformat, 9, 2)
   sMinutes = mid(sDMTFformat, 11, 2)
   sSeconds = mid(sDMTFformat, 13, 2)

   ConvWMIDateTime = sYear & "-" & sMonth & "-" & sDay & " " _
                & sHour & ":" & sMinutes

   If IsNumeric(iNamedFormat) Then
     If iNamedFormat >= 0 And iNamedFormat <= 4 Then
       ' FormatDateTime will set date format to specified format
       ConvWMIDateTime = FormatDateTime(ConvWMIDateTime, iNamedFormat)
     End If
   End If
End Function

RE: yyyymmddhhmm date format

prob a ton of ways..but


response.write   year(date)&Month(date)&Day(date)&hour(time)&Minute(time)

RE: yyyymmddhhmm date format

myDateTime = Year(Date) & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2) _
 & Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244

RE: yyyymmddhhmm date format

Thank you all, I've tried with PHV's answer (with minor changes), and it works great!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close