Solved

date format

Posted on 2003-11-25
7
771 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

778 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