Solved

date format

Posted on 2003-11-25
7
750 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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

14 Experts available now in Live!

Get 1:1 Help Now