Solved

Date Not working correctly

Posted on 2006-11-16
18
426 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now