Date and Time function Help in 3.8 SP1

Advanced techniques applicable to any version of CMM-Manager
Post Reply
New User
New User
Posts: 1
Joined: Fri Oct 18, 2019 9:05 am

Date and Time function Help in 3.8 SP1

Post by LBB2019 » Fri Oct 18, 2019 9:35 am

Hello all, new to the forum so I just want to say thanks in advance for any assistance.

In version 2.5 I used this code to pull and format the Date and Time:

Code: Select all

DateTime = (Format(now, "yymmdd_hhmmss"))
I have just switched to 3.8 SP1 and this function is giving me errors. I searched the forum and have been unsuccessful in finding a solution to the old code. There are other Date functions that do work, but I'd really prefer to have the date and time formatted in that specific manner.

Please help! Thank you!

Posts: 423
Joined: Fri Mar 13, 2015 11:59 am

Re: Date and Time function Help in 3.8 SP1

Post by medupriest » Tue Oct 22, 2019 10:16 am

Hello and welcome to the forum. I am not sure if you saw that there is also a 3.8 and newer section of the advanced programming viewforum.php?f=63. I am not sure if there is an answer there, but if the script has changes since we moved to a 64-bit scripting engine, I will make sure we do add an entry.

User avatar
Site Admin
Site Admin
Posts: 596
Joined: Thu Feb 09, 2017 4:07 pm

Re: Date and Time function Help in 3.8 SP1

Post by CrashN8 » Wed Oct 23, 2019 10:05 am

LBB2019 - Hi there.

You will need to make adjustment to VBScript as mentioned above. Please see details below:

Code: Select all

fromDate = FormatDateTime(Now(),2)
fromTime = FormatDateTime(Now(),3)

MsgBox("Current Date: " + fromDate +Chr(10) + "Current Time: " + fromTime)
This results in MsgBox() as shown here:
You can find details on the VB FormatDateTime() function here -
You do not have the required permissions to view the files attached to this post.

User avatar
Posts: 2
Joined: Wed May 20, 2015 2:30 pm

Re: Date and Time function Help in 3.8 SP1

Post by vudinwe » Wed Oct 23, 2019 10:08 am

Hi, the previous formatting constant "yymmdd_hhmmss" has been deprecated and no longer supported in the new MS VBScript engine.

Below is a sample code that will yield similar output as you expect: 191022_153345

Code: Select all

myDate = FormatDateTime((Now),0)

myYr  = Right("0" & DatePart("yyyy", myDate),2)
myMon = Right("0" & DatePart("m", myDate),2)
myDay = Right("0" & DatePart("d", myDate),2)
myHr  = Right("0" & DatePart("h", myDate),2)
myMin = Right("0" & DatePart("m", myDate),2)
mySec = Right("0" & DatePart("s", myDate),2)

yymmdd_hhmmss = CStr(myYr & myMon & myDay &"_"& myHr & myMin & mySec)
MsgBox yymmdd_hhmmss 
Refer to the references below for explanation of the functions used in the above example:

Post Reply