?
Solved

Date Not working correctly

Posted on 2006-11-16
18
Medium Priority
?
444 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

770 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