• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 457
  • Last Modified:

Date Not working correctly

Hi i have a script to create a date but it doesn't seem to work on a Server it crashes at the point......(MSSTDFMT)

Function Format(vExpression, sFormat)
        set fmt = CreateObject("MSSTDFMT.StdDataFormat")
        fmt.Format = sFormat
        set rs = CreateObject("ADODB.Recordset")
        rs.Fields.Append "fldExpression", 12 ' adVariant
        rs.Open
        rs.AddNew
        set rs("fldExpression").DataFormat = fmt
        rs("fldExpression").Value = vExpression
        Format = rs("fldExpression").Value
        rs.close: Set rs = Nothing: Set fmt = Nothing
End Function
strCDate = format(now(),"dd-mm-yyyy")
0
dion_p1
Asked:
dion_p1
  • 7
  • 6
  • 5
1 Solution
 
NightmanCTOCommented:
What error are you getting?
0
 
dion_p1Author Commented:
ActiveX component cant create object......

How ever it works fin on my laptop?
0
 
NightmanCTOCommented:
The MSSTDFMT.DLL is not registered on the machine
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
NightmanCTOCommented:
It should be located at C:\WINDOWS\system32\msstdfmt.dll
0
 
Shiju SasidharanAssoc Project ManagerCommented:
have u registered MSSTDFMT.DLL on ur server?

>>Function Format(vExpression, sFormat)
also try to change your function name, since "Format" is an existing VBA function


0
 
Shiju SasidharanAssoc Project ManagerCommented:
little bit late i think ;-)
0
 
NightmanCTOCommented:
The dll may not be on the machine - it is installed by visual studio 6.

You should be able to copy it to the C:\WINDOWS\system32 folder on the target machine and then register it
to register, run regsvr32 "C:\WINDOWS\system32\msstdfmt.dll" from the command prompt (start, run)
0
 
dion_p1Author Commented:
Is their not a way to generate a Current Date thats dependant on a solution such as this?
0
 
NightmanCTOCommented:
Try removing your Format function and simply doing this:

strCDate = format(now(),"dd-mm-yyyy")

This is a standard (and default) VB function.
0
 
NightmanCTOCommented:
It just occurred to me - are you using VBScript? If so, stick with your current solution (and copy and register the dll)
0
 
dion_p1Author Commented:
I get type mismatch at the part "Format(....)"
0
 
dion_p1Author Commented:
Is there any other way without having to register a dll?
0
 
NightmanCTOCommented:
Not if you are using VBScript.

The alternative would be to write your own prodecure in VBS to handle this which would be more time consuming and probalby prone to errors.
0
 
Shiju SasidharanAssoc Project ManagerCommented:
>>I get type mismatch at the part "Format(....)"

Give the entire line throwing error
0
 
dion_p1Author Commented:
Error: Type Mismatch: 'format
Code: 800A000D
Scource: Microsoft VBScript runtime error
0
 
Shiju SasidharanAssoc Project ManagerCommented:
no no , i mean the line in ur code
0
 
Shiju SasidharanAssoc Project ManagerCommented:
strCDate = Now()
strCDate = Day(strCDate) & "-" & Month(strCDate) & "-" & Year(strCDate)
0
 
Shiju SasidharanAssoc Project ManagerCommented:
or you need to use  FormatDateTime Function

http://www.w3schools.com/vbscript/func_formatdatetime.asp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 7
  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now