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
Solved

date format

Posted on 2003-11-25
7
777 Views
Last Modified: 2011-10-03
How do I change Month(Date) from giving me the number to the 3 letter equivalent?
0
Comment
Question by:craigs052998
  • 3
  • 2
  • 2
7 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 9818205
Hi craigs,

Use Format(MyDateValue,"mmm")

Instead.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 

Author Comment

by:craigs052998
ID: 9818270

How would I change that in my code?

sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Day(Date) & "_" & Month(Date) & "_" & Year(Date) &".mdc"

Like this????
sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Day(Date) & "_" & Format(Date,"mmm") & "_" & Year(Date) &".mdc"


0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9818296
Exactly.

AW
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 44

Expert Comment

by:Arthur_Wood
ID: 9818307
in fact, you can do it all at once:

sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

AW
0
 

Author Comment

by:craigs052998
ID: 9818402

I get an error on line 18 char 1 TypeMissmatch:'Format'

Oh and this is also done as a vbs file if that matters



Dim oFSO
Dim sSourceFile_1
Dim sSourceFile_2
Dim sSourceFile_3
Dim sSourceFile_4
Dim sDestinationFile_1
Dim sDestinationFile_2
Dim sDestinationFile_3
Dim sDestinationFile_4
Dim MvLoc
Dim SysDate
Dim FSys


Set oFSO = CreateObject("Scripting.FileSystemObject")

sSourceFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory.mdc"
sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

sSourceFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure.mdc"
sDestinationFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

sSourceFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance.mdc"
sDestinationFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

sSourceFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking.mdc"
sDestinationFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking_" & Format(Date,"dd_mmm_yyyy") & ".mdc"

MvLoc = "\\namcfmsolfs012\ftpshare\REOArchive\"

oFSO.CopyFile sSourceFile_1,sDestinationFile_1
oFSO.CopyFile sSourceFile_2,sDestinationFile_2
oFSO.CopyFile sSourceFile_3,sDestinationFile_3
oFSO.CopyFile sSourceFile_4,sDestinationFile_4

oFSO.MoveFile sDestinationFile_1,MvLoc
oFSO.MoveFile sDestinationFile_2,MvLoc
oFSO.MoveFile sDestinationFile_3,MvLoc
oFSO.MoveFile sDestinationFile_4,MvLoc








0
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 9818489
And there is the problem, VBScript doesn't support the Format() function. You do have the FormatDateTime option though this doesn't allow you to specify the format in the same way.

If your system's long date format in regional settings is dd/mmm/yyyy you could use replace to change the / to _ or you have to handle it in a function call:

Dim oFSO
Dim sSourceFile_1
Dim sSourceFile_2
Dim sSourceFile_3
Dim sSourceFile_4
Dim sDestinationFile_1
Dim sDestinationFile_2
Dim sDestinationFile_3
Dim sDestinationFile_4
Dim MvLoc
Dim SysDate
Dim FSys


Set oFSO = CreateObject("Scripting.FileSystemObject")

sSourceFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory.mdc"
sDestinationFile_1 = "C:\PowerPlay\CubesToPublish\C001_reo_ie_active_inventory_" & GetTheDate() & ".mdc"

sSourceFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure.mdc"
sDestinationFile_2 = "C:\PowerPlay\CubesToPublish\c002_reo_ie_post_foreclosure_" & GetTheDate() & ".mdc"

sSourceFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance.mdc"
sDestinationFile_3 = "C:\PowerPlay\CubesToPublish\c003_reo_sales_performance_" & GetTheDate() & ".mdc"

sSourceFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking.mdc"
sDestinationFile_4 = "C:\PowerPlay\CubesToPublish\C004_reo_ie_eviction_tracking_" & GetTheDate() & ".mdc"

MvLoc = "\\namcfmsolfs012\ftpshare\REOArchive\"

oFSO.CopyFile sSourceFile_1,sDestinationFile_1
oFSO.CopyFile sSourceFile_2,sDestinationFile_2
oFSO.CopyFile sSourceFile_3,sDestinationFile_3
oFSO.CopyFile sSourceFile_4,sDestinationFile_4

oFSO.MoveFile sDestinationFile_1,MvLoc
oFSO.MoveFile sDestinationFile_2,MvLoc
oFSO.MoveFile sDestinationFile_3,MvLoc
oFSO.MoveFile sDestinationFile_4,MvLoc

Function GetTheDate()
  Dim intDay
  Dim strMonth
  Dim intMonth
  Dim intYear
  intDay = Day(Date)
  intYear = Year(Date)
  intMonth = Month(Date)
  Select Case intMonth
  Case 1
    strMonth = "Jan"
  Case 2
    strMonth = "Feb"
 ....
  End Select
  GetTheDate = CStr(intDay) & "_" & strMonth & "_" & CStr(intYear)
End Function
0
 

Author Comment

by:craigs052998
ID: 9818549
Bingo
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

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…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

840 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