Solved

Date Not working correctly

Posted on 2006-11-16
18
433 Views
Last Modified: 2008-02-01
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
Comment
Question by:dion_p1
  • 7
  • 6
  • 5
18 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 17954334
What error are you getting?
0
 

Author Comment

by:dion_p1
ID: 17954351
ActiveX component cant create object......

How ever it works fin on my laptop?
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954360
The MSSTDFMT.DLL is not registered on the machine
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 29

Expert Comment

by:Nightman
ID: 17954363
It should be located at C:\WINDOWS\system32\msstdfmt.dll
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954370
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
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954376
little bit late i think ;-)
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954377
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
 

Author Comment

by:dion_p1
ID: 17954383
Is their not a way to generate a Current Date thats dependant on a solution such as this?
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954389
Try removing your Format function and simply doing this:

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

This is a standard (and default) VB function.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954445
It just occurred to me - are you using VBScript? If so, stick with your current solution (and copy and register the dll)
0
 

Author Comment

by:dion_p1
ID: 17954456
I get type mismatch at the part "Format(....)"
0
 

Author Comment

by:dion_p1
ID: 17954500
Is there any other way without having to register a dll?
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17954524
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
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954574
>>I get type mismatch at the part "Format(....)"

Give the entire line throwing error
0
 

Author Comment

by:dion_p1
ID: 17954594
Error: Type Mismatch: 'format
Code: 800A000D
Scource: Microsoft VBScript runtime error
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954615
no no , i mean the line in ur code
0
 
LVL 14

Accepted Solution

by:
Shiju Sasidharan earned 500 total points
ID: 17954832
strCDate = Now()
strCDate = Day(strCDate) & "-" & Month(strCDate) & "-" & Year(strCDate)
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17954843
or you need to use  FormatDateTime Function

http://www.w3schools.com/vbscript/func_formatdatetime.asp
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question